Commit 030d6bdf by github-actions

Transpile b2ca8974

parent 14cff4c6
name: Merge upstream
on:
push:
branches: [patches]
workflow_dispatch: {}
schedule:
- cron: '0 10 * * *'
repository_dispatch:
types: [Update]
# client_payload: { ref: string }
concurrency:
group: merge-${{ github.event.client_payload.ref || github.ref }}
cancel-in-progress: true
jobs:
update:
merge:
runs-on: ubuntu-latest
steps:
- uses: rokroskar/workflow-run-cleanup-action@v0.2.2
env:
GITHUB_TOKEN: ${{github.token}}
- uses: actions/checkout@v2
with:
ref: upstream-patched
ref: patches
fetch-depth: 0
ssh-key: ${{secrets.DEPLOY_KEY}}
ssh-key: ${{ secrets.DEPLOY_KEY }}
- run: bash scripts/upgradeable/git-user-config.sh
- run: bash scripts/upgradeable/merge-upstream.sh
- run: git push
env:
REF: ${{ github.event.client_payload.ref || github.ref}}
- run: git push origin HEAD
......@@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 10.x
node-version: 12.x
- uses: actions/cache@v2
id: cache
with:
......
......@@ -3,23 +3,26 @@ name: Transpile
on:
workflow_dispatch: {}
push:
branches: [upstream-patched]
branches: [patched/*]
concurrency:
group: transpile
cancel-in-progress: true
jobs:
transpile:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/heads/patched/')
steps:
- uses: rokroskar/workflow-run-cleanup-action@v0.2.2
env:
GITHUB_TOKEN: ${{github.token}}
- run: echo ::set-output name=name::"${GITHUB_REF#refs/heads/patched/}"
id: branch
- uses: actions/checkout@v2
with:
ref: upstream-patched
fetch-depth: 0
ssh-key: ${{secrets.DEPLOY_KEY}}
ssh-key: ${{ secrets.DEPLOY_KEY }}
- uses: actions/setup-node@v1
with:
node-version: 10.x
node-version: 12.x
- uses: actions/cache@v2
id: cache
with:
......@@ -29,5 +32,5 @@ jobs:
- run: npm ci
if: steps.cache.outputs.cache-hit != 'true'
- run: bash scripts/upgradeable/git-user-config.sh
- run: bash scripts/upgradeable/transpile-onto.sh master origin/master
- run: git push origin master
- run: bash scripts/upgradeable/transpile-onto.sh ${{ steps.branch.outputs.name }} origin/${{ steps.branch.outputs.name }}
- run: git push origin ${{ steps.branch.outputs.name }}
......@@ -2,33 +2,33 @@
## [Branches](https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/branches)
### `upstream-patched`
### `patches`
Contains a patched version of the vanilla Contracts repo. It adds the scripts to transpile and GitHub Actions for it to work automatically, changes the package name, etc.
Built on top of the `master` branch of the vanilla Contracts repo, contains the changes necessary to build this package: it adds the scripts to transpile and GitHub Actions for it to work automatically, changes the package name, etc.
Eventually it may also include small changes to the Solidity code, such as reordering of state variables, in order to ensure storage compatibility.
It can also include small changes to the Solidity code, such as reordering of state variables, in order to ensure storage compatibility.
It's an important goal that this branch should be easy to merge with the vanilla Contracts repo, avoiding merge conflicts as much as possible. This is necessary to reduce manual intervention and ensure automation runs smoothly.
### `master`
This branch will not necessarily be up to date with the vanilla `master` branch, only up to the point necessary to guarantee successful merging with any new updates. In some cases it will be necessary to apply a manual merge with new changes, it is this branch that should be updated for the changes to propagate to all other branches.
Contains the actual transpiled code, which is generated automatically based on `upstream-patched`. The contents of this branch should never be manually changed, because they will be overwritten automatically with the transpiled version of `upstream-patched`. Instead, changes should be made in `upstream-patched`.
### `patched/master`, `patched/release-vX.Y`
### `upstream-v3.2.0-patched`, `release-v3.2.0`
These branches are the merge between `patches` and the corresponding branch from vanilla Contracts. These branches should generally not be updated manually.
I created thes branches in order to release `v3.2.0`, because the `master` branch was already ahead. The first is vanilla v3.2.0 with `upstream-patched` rebased onto it. The second is the transpiled version built using the script shown below.
### `master`, `release-vX.Y`
Contains the transpiled code corresponding to the branch from vanilla Contracts of the same name. These are generated automatically based on their `patched/*` branch. These branches should never be manually updated, because they will be overwritten automatically with the transpiled version of `patched/*`. Instead, changes should be made in `patches`.
## [Actions Workflows](https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/actions)
### [Merge upstream](/.github/workflows/merge-upstream.yml)
All this does is fetch the latest changes from vanilla Contracts repo, tries to merge them into `upstream-patched`, and then pushes the updated branch. If the merge has conflicts, the worfklow will fail. We should be notified of this so that we can manually run the merge and resolve the conflicts. This should not happen often.
Runs on a schedule every morning. Can also be triggered manually from the Actions page.
All this does is fetch the latest changes from a corresponding branch in the vanilla Contracts repo, tries to merge them with `patches`, and then pushes the updated branch to `patched/*`. If the merge has conflicts, the worfklow will fail. We should be notified of this so that we can updated the `patches` branch resolving conflicts and trigger the merge again. This should not happen often.
### [Transpile](/.github/workflows/transpile.yml)
Runs every time `upstream-patched` is pushed to (for example as part of the Merge upstream workflow), transpiles the contents of that branch, and pushes the results as a new commit on the `master` branch.
Runs every time a `patched/*` branch is pushed to (for example as part of the Merge upstream workflow), transpiles the contents of that branch, and pushes the results as a new commit on the transpiled branch.
### [Test](/.github/workflows/test.yml)
......
#!/usr/bin/env bash
set -euo pipefail -x
set -euo pipefail
git fetch 'https://github.com/OpenZeppelin/openzeppelin-contracts.git'
git merge FETCH_HEAD -m 'Merge upstream openzeppelin-contracts into upstream-patched'
: "${REF:="$(git rev-parse --symbolic-full-name HEAD)"}"
if [[ "$REF" != refs/heads/* ]]; then
echo "$REF is not a branch" >&2
exit 1
elif [[ "$REF" == refs/heads/patches ]]; then
REF=refs/heads/master
fi
set -x
input="${REF#refs/heads/}"
upstream="${input#patched/}"
branch="patched/$upstream"
git checkout "$branch" 2>/dev/null || git checkout -b "$branch" origin/patches --no-track
git fetch 'https://github.com/OpenZeppelin/openzeppelin-contracts.git' master
merge_base="$(git merge-base origin/patches FETCH_HEAD)"
git fetch 'https://github.com/OpenZeppelin/openzeppelin-contracts.git' "$upstream"
# Check that patches is not ahead of the upstream branch we're merging.
if ! git merge-base --is-ancestor "$merge_base" FETCH_HEAD; then
echo "The patches branch is ahead of $upstream" >&2
exit 1
fi
git merge origin/patches FETCH_HEAD -m "Merge upstream $upstream into $branch"
......@@ -21,12 +21,12 @@ git add contracts
git checkout --quiet --detach
if git rev-parse --quiet --verify "$target"; then
if git rev-parse -q --verify "$target"; then
git reset --soft "$target"
git checkout "$target"
else
git checkout --orphan "$target"
if [ -n "$base" ]; then
if [ -n "$base" ] && git rev-parse -q --verify "$base"; then
git reset --soft "$base"
fi
fi
......
......@@ -8,7 +8,7 @@ npm run compile
# -i: use included Initializable
# -x: exclude all proxy contracts except Clones library
# -p: emit public initializer
npx @openzeppelin/upgrade-safe-transpiler -D \
npx @openzeppelin/upgrade-safe-transpiler@^0.1.0 -D \
-i contracts/proxy/Initializable.sol \
-x 'contracts/proxy/**/*' \
-x '!contracts/proxy/Clones.sol' \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment