From bd9215cdc9aa9b450b8a2db3079cbee13ee6a292 Mon Sep 17 00:00:00 2001 From: Thomas Burton Date: Wed, 13 Sep 2023 16:53:30 +0200 Subject: [PATCH] chore: validate script skips if chainspec exists --- .github/workflows/_60_create_chainspec.yml | 26 +++++++++++++--------- .github/workflows/release-perseverance.yml | 6 +++++ .github/workflows/release-sisyphos.yml | 6 +++++ .github/workflows/release-test.yml | 7 ------ ci/scripts/create_chainspec.py | 2 +- 5 files changed, 29 insertions(+), 18 deletions(-) diff --git a/.github/workflows/_60_create_chainspec.yml b/.github/workflows/_60_create_chainspec.yml index 4a97a1b932..e10de4eaef 100644 --- a/.github/workflows/_60_create_chainspec.yml +++ b/.github/workflows/_60_create_chainspec.yml @@ -17,39 +17,45 @@ jobs: - name: Checkout uses: actions/checkout@v3 + - name: Check if the chainspec file already exists + id: check-chainspec-exists + continue-on-error: true + run: | + if [ -f state-chain/node/chainspecs/${{ inputs.network }}.chainspec.raw.json ]; then + echo "Chainspec already exists, skipping" + exit 1 + fi + - name: Configure AWS credentials using OIDC + if: steps.check-chainspec-exists.outcome == 'failure' uses: aws-actions/configure-aws-credentials@v2 with: aws-region: eu-central-1 role-to-assume: arn:aws:iam::962042992619:role/chainflip-github-bot - name: Download binary artifacts + if: steps.check-chainspec-exists.outcome == 'failure' uses: actions/download-artifact@v3 with: name: chainflip-backend-bin-ubuntu-22.04 - name: Setup python + if: steps.check-chainspec-exists.outcome == 'failure' uses: actions/setup-python@v3 - name: Create chainspec + if: steps.check-chainspec-exists.outcome == 'failure' run: | python3 ./ci/scripts/create_chainspec.py ${{ inputs.network }} ./chainflip-node - - name: Upload artifact - if: always() - uses: actions/upload-artifact@v3 - with: - name: chainspec - path: | - chainspec.json - chainspec.raw.json - - uses: EndBug/add-and-commit@v9 + if: steps.check-chainspec-exists.outcome == 'failure' with: default_author: github_actions add: state-chain/node/chainspecs/*.json message: "Create chainspec for ${{ inputs.network }}" - name: Upload chainspec to s3 + if: steps.check-chainspec-exists.outcome == 'failure' run: | - aws s3 cp state-chain/node/chainspecs/test.chainspec.raw.json s3://repo.chainflip.io/chainspecs/test.chainspec.json \ No newline at end of file + aws s3 cp state-chain/node/chainspecs/${{ inputs.network }}.chainspec.raw.json s3://repo.chainflip.io/chainspecs/${{ inputs.network }}.chainspec.json \ No newline at end of file diff --git a/.github/workflows/release-perseverance.yml b/.github/workflows/release-perseverance.yml index e7b88862fd..d21994718e 100644 --- a/.github/workflows/release-perseverance.yml +++ b/.github/workflows/release-perseverance.yml @@ -36,6 +36,12 @@ jobs: version: "perseverance/" environment: prod secrets: inherit + chainspec: + needs: [publish] + uses: ./.github/workflows/_60_create_chainspec.yml + secrets: inherit + with: + network: perseverance release: needs: [publish] uses: ./.github/workflows/_50_release.yml diff --git a/.github/workflows/release-sisyphos.yml b/.github/workflows/release-sisyphos.yml index 14f71b1575..0d0a1daddb 100644 --- a/.github/workflows/release-sisyphos.yml +++ b/.github/workflows/release-sisyphos.yml @@ -39,6 +39,12 @@ jobs: needs: [build] uses: ./.github/workflows/_40_post_check.yml secrets: inherit + chainspec: + needs: [build] + uses: ./.github/workflows/_60_create_chainspec.yml + secrets: inherit + with: + network: sisyphos publish: needs: [package] uses: ./.github/workflows/_30_publish.yml diff --git a/.github/workflows/release-test.yml b/.github/workflows/release-test.yml index c8b27368a3..5b90c00d6c 100644 --- a/.github/workflows/release-test.yml +++ b/.github/workflows/release-test.yml @@ -7,14 +7,7 @@ concurrency: cancel-in-progress: true jobs: - build: - uses: ./.github/workflows/_20_build.yml - secrets: inherit - with: - network: test chainspec: - needs: - - build uses: ./.github/workflows/_60_create_chainspec.yml secrets: inherit with: diff --git a/ci/scripts/create_chainspec.py b/ci/scripts/create_chainspec.py index aea74ba1d5..d2f382f747 100644 --- a/ci/scripts/create_chainspec.py +++ b/ci/scripts/create_chainspec.py @@ -23,7 +23,7 @@ chainspec_filename = chainspecs_base_path + network + ".chainspec.json" -generate_chainspec_subprocess=[binary, "build-spec", "--chain", network, "--disable-default-bootnode"] +generate_chainspec_subprocess=[binary, "build-spec", "--chain", network, "-new --disable-default-bootnode"] with open(chainspec_filename, "w") as chainspec: subprocess.call(generate_chainspec_subprocess, stdout=chainspec)