From 8f162fded8fc31b3950e9d6ee5d33f6f91d50b32 Mon Sep 17 00:00:00 2001 From: Przemek Rzad Date: Wed, 6 Mar 2024 10:23:04 +0100 Subject: [PATCH] Add periodic E2E tests against a newest Polkadot release (#147) --- .github/actions/run-polkadot/action.yml | 46 ++++++++++++++++ .github/workflows/test-e2e-cron.yml | 38 +++++++++++++ .github/workflows/test-e2e.yml | 29 ++++++++++ .github/workflows/test-integration.yml | 15 ++++++ .github/workflows/test.yml | 71 ------------------------- README.md | 9 ++++ 6 files changed, 137 insertions(+), 71 deletions(-) create mode 100644 .github/actions/run-polkadot/action.yml create mode 100644 .github/workflows/test-e2e-cron.yml create mode 100644 .github/workflows/test-e2e.yml create mode 100644 .github/workflows/test-integration.yml delete mode 100644 .github/workflows/test.yml diff --git a/.github/actions/run-polkadot/action.yml b/.github/actions/run-polkadot/action.yml new file mode 100644 index 0000000..cbdce30 --- /dev/null +++ b/.github/actions/run-polkadot/action.yml @@ -0,0 +1,46 @@ +name: Run Polkadot action +description: Reusable action to build and run a modified version of Polkadot +inputs: + polkadot-version: + description: 'Version tag, e.g. polkadot-v1.7.1' + required: true + +runs: + using: "composite" + steps: + - uses: actions/checkout@v3.3.0 + with: + path: substrate-tip-bot + - uses: actions/checkout@v3.3.0 + with: + repository: paritytech/polkadot-sdk + ref: ${{ inputs.polkadot-version }} + path: polkadot-sdk + - name: Apply Polkadot patches + run: git apply ../substrate-tip-bot/polkadot.e2e.patch + shell: bash + working-directory: polkadot-sdk + - name: Restore cached Polkadot build + id: polkadot-cache-restore + uses: actions/cache/restore@v3 + with: + path: | + polkadot-sdk/target/release + key: ${{ runner.os }}-${{ inputs.polkadot-version }}-${{ hashFiles('substrate-tip-bot/polkadot.e2e.patch') }} + - name: Build Polkadot + if: steps.polkadot-cache-restore.outputs.cache-hit != 'true' + run: | + cargo build --release --locked --features=fast-runtime -p polkadot + shell: bash + working-directory: polkadot-sdk + - name: Save Polkadot build cache + uses: actions/cache/save@v3 + with: + path: | + polkadot-sdk/target/release + key: ${{ runner.os }}-${{ inputs.polkadot-version }}-${{ hashFiles('substrate-tip-bot/polkadot.e2e.patch') }} + - name: Run a local Rococo node + run: | + polkadot-sdk/target/release/polkadot --rpc-external --no-prometheus --no-telemetry --chain=rococo-dev --tmp --alice --execution Native --rpc-port 9902 & + until curl -s '127.0.0.1:9902'; do sleep 3; done + shell: bash diff --git a/.github/workflows/test-e2e-cron.yml b/.github/workflows/test-e2e-cron.yml new file mode 100644 index 0000000..0c0b220 --- /dev/null +++ b/.github/workflows/test-e2e-cron.yml @@ -0,0 +1,38 @@ +name: E2E tests against most recent Polkadot release +on: + schedule: + - cron: 0 3 * * SUN # Once a week on Sunday. + workflow_dispatch: + +jobs: + test-e2e-cron: + runs-on: ubuntu-22.04 + timeout-minutes: 120 + container: "${{ vars.E2E_TESTS_CONTAINER }}" + steps: + - name: Read latest polkadot tag + id: read-tag + run: | + # Fetch all Polkadot release tags, get the last (newest) one, and parse its name from the output. + TAG=$(git ls-remote --refs --tags https://github.com/paritytech/polkadot-sdk.git 'polkadot-v*' \ + | tail -1 \ + | sed 's,[^r]*refs/tags/,,') + echo "tag=$TAG" >> $GITHUB_OUTPUT + - name: Announce version + run: echo "Running tests with Polkadot version ${{ steps.read-tag.outputs.tag }}" + - uses: actions/checkout@v3.3.0 + - name: Start a local Polkadot node + uses: ./.github/actions/run-polkadot + with: + polkadot-version: "${{ steps.read-tag.outputs.tag }}" + - name: Wait for the node + run: | + until curl -s '127.0.0.1:9902'; do sleep 3; done + timeout-minutes: 1 + - uses: actions/setup-node@v3.5.1 + with: + node-version: "18.16" + - run: npm i -g yarn@1.22.19 + - run: yarn --frozen-lockfile + - run: yarn test:e2e + timeout-minutes: 10 diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml new file mode 100644 index 0000000..7bc435f --- /dev/null +++ b/.github/workflows/test-e2e.yml @@ -0,0 +1,29 @@ +name: E2E tests +on: + pull_request: + push: + branches: + - master + +jobs: + test-e2e: + runs-on: ubuntu-22.04 + timeout-minutes: 120 + container: "${{ vars.E2E_TESTS_CONTAINER }}" + steps: + - uses: actions/checkout@v3.3.0 + - name: Start a local Polkadot node + uses: ./.github/actions/run-polkadot + with: + polkadot-version: polkadot-v1.7.1 + - name: Wait for the node + run: | + until curl -s '127.0.0.1:9902'; do sleep 3; done + timeout-minutes: 1 + - uses: actions/setup-node@v3.5.1 + with: + node-version: "18.16" + - run: npm i -g yarn@1.22.19 + - run: yarn --frozen-lockfile + - run: yarn test:e2e + timeout-minutes: 10 diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml new file mode 100644 index 0000000..d16a402 --- /dev/null +++ b/.github/workflows/test-integration.yml @@ -0,0 +1,15 @@ +name: Integration tests +on: + pull_request: + push: + branches: + - master + +jobs: + test-integration: + timeout-minutes: 15 + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3.3.0 + - run: yarn --frozen-lockfile + - run: yarn test:integration --verbose diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 62baba3..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,71 +0,0 @@ -name: Test -on: - pull_request: - push: - branches: - - master - -jobs: - test-integration: - timeout-minutes: 15 - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v3.3.0 - - run: yarn --frozen-lockfile - - run: yarn test:integration --verbose - - test-e2e: - timeout-minutes: 120 - runs-on: ubuntu-22.04 - container: paritytech/ci-linux:production - env: - POLKADOT_VERSION: 'polkadot-v1.7.1' - - steps: - - uses: actions/checkout@v3.3.0 - with: - path: substrate-tip-bot - - name: Setup Node.js - uses: actions/setup-node@v3.5.1 - with: - node-version: "18.16" - - run: npm i -g yarn@1.22.19 - - run: yarn --frozen-lockfile - working-directory: substrate-tip-bot - - uses: actions/checkout@v3.3.0 - with: - repository: paritytech/polkadot-sdk - ref: ${{ env.POLKADOT_VERSION }} - path: polkadot-sdk - - name: Apply Polkadot patches - run: git apply ../substrate-tip-bot/polkadot.e2e.patch - working-directory: polkadot-sdk - - name: Restore cached Polkadot build - id: polkadot-cache-restore - uses: actions/cache/restore@v3 - with: - path: | - polkadot-sdk/target/release - key: ${{ runner.os }}-${{ env.POLKADOT_VERSION }}-${{ hashFiles('substrate-tip-bot/polkadot.e2e.patch') }} - - name: Build Polkadot - if: steps.polkadot-cache-restore.outputs.cache-hit != 'true' - run: | - rustup update nightly - rustup update stable - rustup target add wasm32-unknown-unknown --toolchain nightly - cargo build --release --locked --features=fast-runtime -p polkadot - working-directory: polkadot-sdk - - name: Save Polkadot build cache - uses: actions/cache/save@v3 - with: - path: | - polkadot-sdk/target/release - key: ${{ runner.os }}-${{ env.POLKADOT_VERSION }}-${{ hashFiles('substrate-tip-bot/polkadot.e2e.patch') }} - - name: Run a local Rococo node - run: | - polkadot-sdk/target/release/polkadot --rpc-external --no-prometheus --no-telemetry --chain=rococo-dev --tmp --alice --execution Native --rpc-port 9902 & - until curl -s '127.0.0.1:9902'; do sleep 3; done - timeout-minutes: 1 - - name: Run the tests - run: yarn test:e2e - working-directory: substrate-tip-bot diff --git a/README.md b/README.md index ee4d172..a4e3338 100644 --- a/README.md +++ b/README.md @@ -151,6 +151,15 @@ yarn test:e2e Go make a cup of tea, the tests take ~3 minutes (waiting for the various on-chain stages to pass). +On CI, the E2E tests are running: + +- On every PR and commits pushed to `master`, against a fixed release of `polkadot-sdk`. +- Periodically, against a most recent release of `polkadot-sdk`. + +The tests are running in a container specified by `E2E_TESTS_CONTAINER` [repository variable](https://docs.github.com/en/actions/learn-github-actions/variables#defining-configuration-variables-for-multiple-workflows). + +The container version should be kept in sync with the container used in [`polkadot-sdk` CI](https://github.com/paritytech/polkadot-sdk/blob/polkadot-v1.7.2/.github/workflows/fmt-check.yml#L18). + ## Contributing If you have suggestions for how substrate-tip-bot could be improved, or want to report a bug, open