Skip to content

Commit

Permalink
merge with main
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptoAtwill committed Feb 29, 2024
2 parents b61bcc8 + 3bcef48 commit 3da4edf
Show file tree
Hide file tree
Showing 91 changed files with 4,883 additions and 1,571 deletions.
123 changes: 123 additions & 0 deletions .github/workflows/auto-deploy-contracts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: Auto deploy IPC contracts when changed

on:
workflow_dispatch:
push:
branches:
- main
paths:
- contracts/**

env:
GIT_USERNAME: github-actions[bot]
GIT_EMAIL: ipc+github-actions[bot]@users.noreply.github.com

concurrency:
# Only allow one run at a time for this workflow
group: auto-deploy-contracts
cancel-in-progress: true

jobs:
deploy-contracts:
runs-on: ubuntu-latest
env:
RPC_URL: https://calibration.filfox.info/rpc/v1
PRIVATE_KEY: ${{ secrets.CONTRACTS_DEPLOYER_PRIVATE_KEY }}
steps:
- name: Checkout cd/contract branch
uses: actions/checkout@v4
with:
ref: cd/contracts
submodules: recursive
fetch-depth: 0

- name: (Dry run) Try merge from main branch to see if there's any conflicts that can't be resolved itself
run: |
git show HEAD
git config --global user.name "$GIT_USERNAME"
git config --global user.email "$GIT_EMAIL"
git checkout main
git pull --rebase origin main
git checkout cd/contracts
git merge main --no-edit --allow-unrelated-histories
- name: Checkout the branch that triggered this run
uses: actions/checkout@v4
with:
# TODO(jie): After switch to workflow_dispatch only, we should use ref_name.
# head_ref only works for workflow triggered by pull requests.
# ref: ${{ github.ref_name }}
ref: ${{ github.head_ref }}
submodules: recursive

- name: Setup node and npm
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
cache-dependency-path: contracts/package-lock.json

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Deploy IPC contracts to calibration net
id: deploy_contracts
run: |
cd contracts
npm install --save hardhat
output=$(make deploy-ipc NETWORK=calibrationnet)
echo "deploy_output<<EOF" >> $GITHUB_OUTPUT
echo "$output" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Parse deploy output
run: |
deploy_output='${{ steps.deploy_contracts.outputs.deploy_output }}'
echo "$deploy_output"
deployed_gateway_address=$(echo "$deploy_output" | grep '"Gateway"' | awk -F'"' '{print $4}')
deployed_registry_address=$(echo "$deploy_output" | grep '"SubnetRegistry"' | awk -F'"' '{print $4}')
echo "gateway_address=$deployed_gateway_address" >> $GITHUB_ENV
echo "registry_address=$deployed_registry_address" >> $GITHUB_ENV
echo "commit_hash=$(git rev-parse HEAD)" >> $GITHUB_ENV
- name: Review deployed addresses
run: |
echo "commit_hash: $commit_hash"
echo "gateway_address: $gateway_address"
echo "registry_address: $registry_address"
- name: Switch code repo to cd/contract branch
uses: actions/checkout@v4
with:
ref: cd/contracts
submodules: recursive
fetch-depth: 0

- name: Merge from main branch and update cd/contracts branch
run: |
git config --global user.name "$GIT_USERNAME"
git config --global user.email "$GIT_EMAIL"
git checkout main
git pull --rebase origin main
git checkout cd/contracts
git merge main --no-edit --allow-unrelated-histories
git push -f origin cd/contracts
- name: Write deployed address to output file
run: |
mkdir -p deployments
json_str='{"commit":"'$commit_hash'","gateway_addr":"'$gateway_address'","registry_addr":"'$registry_address'"}'
jq -n "$json_str" > deployments/r314159.json
cat deployments/r314159.json
- name: Commit output file and push it to remote repo
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Update contract address
branch: cd/contracts
file_pattern: deployments/r314159.json
commit_user_name: ${{env.GIT_USERNAME}}
commit_user_email: ${{env.GIT_EMAIL}}
push_options: '--force'
skip_dirty_check: true
create_branch: true
31 changes: 24 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ on:
push:
branches:
- main
# Pattern matched against refs/tags
tags:
# Push events to every git tag not containing /
# NOTE: '**' would match tags with / in them, e.g. "foo/bar",
# but we want to use the tag as a docker tag as well, so it's best avoided.
- '*'

pull_request:
branches:
- '**'
Expand Down Expand Up @@ -57,7 +64,8 @@ jobs:
needs: [changes]
if: >-
needs.changes.outputs.contracts == 'true' ||
github.ref == 'refs/heads/main'
github.ref == 'refs/heads/main' ||
github.ref_type == 'tag'
contracts-deployment-test:
uses: ./.github/workflows/contracts-deployment-test.yaml
Expand All @@ -79,22 +87,28 @@ jobs:
uses: ./.github/workflows/contracts-sast.yaml
needs: [contracts-prettier]

extras:
uses: ./.github/workflows/extras.yaml
needs: [contracts-prettier]

ipc:
uses: ./.github/workflows/ipc.yaml
needs: [changes, license]
if: >-
needs.changes.outputs.workspace == 'true' ||
needs.changes.outputs.contracts == 'true' ||
needs.changes.outputs.ipc == 'true' ||
github.ref == 'refs/heads/main'
github.ref == 'refs/heads/main' ||
github.ref_type == 'tag'
ipld-resolver:
uses: ./.github/workflows/ipld-resolver.yaml
needs: [changes, license]
if: >-
needs.changes.outputs.workspace == 'true' ||
needs.changes.outputs.ipld-resolver == 'true' ||
github.ref == 'refs/heads/main'
github.ref == 'refs/heads/main' ||
github.ref_type == 'tag'
fendermint-test:
uses: ./.github/workflows/fendermint-test.yaml
Expand All @@ -106,7 +120,8 @@ jobs:
needs.changes.outputs.ipc == 'true' ||
needs.changes.outputs.ipld-resolver == 'true' ||
needs.changes.outputs.fendermint == 'true' ||
github.ref == 'refs/heads/main'
github.ref == 'refs/heads/main' ||
github.ref_type == 'tag'
fevm-contract-tests:
uses: ./.github/workflows/fevm-contract-tests.yaml
Expand All @@ -118,8 +133,8 @@ jobs:
needs.changes.outputs.ipc == 'true' ||
needs.changes.outputs.ipld-resolver == 'true' ||
needs.changes.outputs.fendermint == 'true' ||
github.ref == 'refs/heads/main'
github.ref == 'refs/heads/main' ||
github.ref_type == 'tag'
fendermint-publish:
uses: ./.github/workflows/fendermint-publish.yaml
Expand All @@ -128,7 +143,9 @@ jobs:
# It is because of these needs that all the filters are allowed to run on `main` too, otherwise this would be disabled.
# It could be done in a more granular approach inside the workflows to allow the job to pass but opt-out of testing,
# but I guess it doesn't hurt to run a final round of unconditional tests, even though it takes longer to publish.
if: github.ref == 'refs/heads/main'
if: >-
github.ref == 'refs/heads/main' ||
github.ref_type == 'tag'
needs:
- contracts-test # generates the ABI artifacts (although fendermint can do on its own too)
- ipc
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/contracts-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
with:
cache: false

- name: Cache Solidity ABI arfiacts
- name: Cache Solidity ABI artifacts
uses: actions/cache@v2
with:
path: ./contracts/out
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/extras.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Extras

on:
workflow_call:

env:
FOUNDRY_PROFILE: ci

jobs:
examples-axelar-token:
name: "Extras: Axelar token"
runs-on: ubuntu-latest
strategy:
fail-fast: true
defaults:
run:
working-directory: ./extras/axelar-token
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Run Forge build
id: build
run: |
forge --version
forge build --sizes
- name: Run Forge tests
id: test
run: |
forge test -vvvv
3 changes: 1 addition & 2 deletions .github/workflows/fendermint-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ jobs:
# Publish Docker image on the main branch
publish:
name: Publish artifacts
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest

permissions:
Expand Down Expand Up @@ -74,7 +73,7 @@ jobs:
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# This strips the "v" prefix from the tag name.
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# This uses the Docker `latest` tag convention.
[ "$VERSION" == "main" ] && VERSION=latest
Expand Down
11 changes: 8 additions & 3 deletions .github/workflows/fendermint-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,13 @@ jobs:
make:
- name: Clippy
task: check-clippy
- name: Test
task: test
# Technically it's not necessary to build, testing would be fine on its own.
# However, tests bring in dev-dependencies, and without them something might not compile,
# which we want to catch as it would mean the `cargo build` in the docs would fail.
# Doing it a one step so build artifacts can be reused by the tests, minimising the overhead.
- name: Build and Test
task: build test
# Tests that involve docker.
- name: End-to-End
task: e2e
exclude:
Expand Down Expand Up @@ -97,4 +102,4 @@ jobs:
- name: ${{ matrix.make.name }}
env:
PROMTAIL_CLIENT_URL: ${{ secrets.PROMTAIL_CLIENT_URL }}
run: cd fendermint && make ${{ matrix.make.task }}
run: cd fendermint && make ${{ matrix.make.task }}
12 changes: 12 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,15 @@
[submodule "contracts/lib/forge-std"]
path = contracts/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "extras/axelar-token/lib/axelar-gmp-sdk-solidity"]
path = extras/axelar-token/lib/axelar-gmp-sdk-solidity
url = https://github.com/axelarnetwork/axelar-gmp-sdk-solidity
[submodule "extras/axelar-token/lib/interchain-token-service"]
path = extras/axelar-token/lib/interchain-token-service
url = https://github.com/axelarnetwork/interchain-token-service
[submodule "extras/axelar-token/lib/openzeppelin-contracts"]
path = extras/axelar-token/lib/openzeppelin-contracts
url = https://github.com/openzeppelin/openzeppelin-contracts
[submodule "extras/axelar-token/lib/forge-std"]
path = extras/axelar-token/lib/forge-std
url = https://github.com/foundry-rs/forge-std
Loading

0 comments on commit 3da4edf

Please sign in to comment.