Skip to content

Commit

Permalink
feat: move gasp-node unit tests and coverage report runs to separate …
Browse files Browse the repository at this point in the history
…reusable job
  • Loading branch information
tenequm committed Jan 21, 2025
1 parent 2531e7b commit b22c7ad
Show file tree
Hide file tree
Showing 4 changed files with 251 additions and 196 deletions.
39 changes: 26 additions & 13 deletions .github/workflows/branch-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,20 @@ jobs:
version: ${{ needs.init.outputs.GLOBAL_VERSION }}
branch: ${{ needs.init.outputs.GIT_BRANCH }}

gasp-node-unit-tests-and-coverage:
name: '[gasp-node] Run unit tests and coverage'
needs: [init]
uses: ./.github/workflows/reusable-gasp-node-unit-tests-and-coverage.yml
secrets: inherit
permissions:
contents: read
actions: read
checks: write
id-token: write
with:
version: ${{ needs.init.outputs.GLOBAL_VERSION }}
branch: ${{ needs.init.outputs.GIT_BRANCH }}

gasp-node-generate-types:
name: '[gasp-node] Generate types'
needs: [init, build-and-test-gasp-node]
Expand All @@ -78,22 +92,21 @@ jobs:
with:
globalVersion: ${{ needs.init.outputs.GLOBAL_VERSION }}

# TODO: Remove after testing
# run-e2e-test-gasp-node:
# name: '[gasp-node] Run e2e tests'
# needs: [init, build-and-test-gasp-node, gasp-node-generate-types]
# uses: ./.github/workflows/reusable-gasp-node-e2e-tests.yml
# secrets: inherit
# permissions:
# contents: read
# actions: read
# checks: write
# with:
# globalVersion: ${{ needs.init.outputs.GLOBAL_VERSION }}
run-e2e-test-gasp-node:
name: '[gasp-node] Run e2e tests'
needs: [init, build-and-test-gasp-node, gasp-node-generate-types]
uses: ./.github/workflows/reusable-gasp-node-e2e-tests.yml
secrets: inherit
permissions:
contents: read
actions: read
checks: write
with:
globalVersion: ${{ needs.init.outputs.GLOBAL_VERSION }}

deploy-dev:
name: Deploy `dev` environment
needs: [init, build-and-test, build-and-test-gasp-node]
needs: [init, build-and-test, build-and-test-gasp-node, gasp-node-unit-tests-and-coverage]
uses: ./.github/workflows/reusable-deploy.yml
secrets: inherit
with:
Expand Down
43 changes: 28 additions & 15 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ jobs:
build-and-test:
needs: [init]
name: Build AVS services
name: '[AVS services] Build'
uses: ./.github/workflows/reusable-build-and-test.yml
secrets: inherit
with:
version: ${{ needs.init.outputs.GLOBAL_VERSION }}

build-and-test-gasp-node:
needs: [init]
name: Build gasp-node
name: '[gasp-node] Build'
uses: ./.github/workflows/reusable-gasp-node-build-and-test.yml
secrets: inherit
permissions:
Expand All @@ -57,6 +57,20 @@ jobs:
with:
version: ${{ needs.init.outputs.GLOBAL_VERSION }}
branch: ${{ needs.init.outputs.GIT_BRANCH }}

gasp-node-unit-tests-and-coverage:
name: '[gasp-node] Run unit tests and coverage'
needs: [init]
uses: ./.github/workflows/reusable-gasp-node-unit-tests-and-coverage.yml
secrets: inherit
permissions:
contents: read
actions: read
checks: write
id-token: write
with:
version: ${{ needs.init.outputs.GLOBAL_VERSION }}
branch: ${{ needs.init.outputs.GIT_BRANCH }}

gasp-node-generate-types:
name: '[gasp-node] Generate types'
Expand All @@ -79,25 +93,24 @@ jobs:
with:
globalVersion: ${{ needs.init.outputs.GLOBAL_VERSION }}

# TODO: Remove after testing
# run-e2e-test-gasp-node:
# name: '[gasp-node] Run e2e tests'
# needs: [init, build-and-test-gasp-node, gasp-node-generate-types]
# uses: ./.github/workflows/reusable-gasp-node-e2e-tests.yml
# secrets: inherit
# permissions:
# contents: read
# actions: read
# checks: write
# with:
# globalVersion: ${{ needs.init.outputs.GLOBAL_VERSION }}
run-e2e-test-gasp-node:
name: '[gasp-node] Run e2e tests'
needs: [init, build-and-test-gasp-node, gasp-node-generate-types]
uses: ./.github/workflows/reusable-gasp-node-e2e-tests.yml
secrets: inherit
permissions:
contents: read
actions: read
checks: write
with:
globalVersion: ${{ needs.init.outputs.GLOBAL_VERSION }}

deploy-fungible:
name: Deploy fungible environment
if: |
(github.event_name == 'pull_request' && github.event.action == 'labeled' && github.event.label.name == ':rocket: deploy_fungible') ||
(github.event_name == 'pull_request' && github.event.action != 'labeled' && contains(github.event.pull_request.labels.*.name, ':rocket: deploy_fungible'))
needs: [init, build-and-test, build-and-test-gasp-node]
needs: [init, build-and-test, build-and-test-gasp-node, gasp-node-unit-tests-and-coverage]
uses: ./.github/workflows/reusable-deploy.yml
secrets: inherit
with:
Expand Down
169 changes: 1 addition & 168 deletions .github/workflows/reusable-gasp-node-build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ on:

permissions:
contents: read
actions: read
checks: write
id-token: write

Expand Down Expand Up @@ -559,160 +558,6 @@ jobs:
SECONDS=0; gcloud storage cp "$ARCHIVE_NAME" "gs://mangata-node-ci-cache/$CACHE_KEY/$ARCHIVE_NAME"
echo "Upload completed in $SECONDS seconds"
unit-test:
name: '[gasp-node] Unit tests'
runs-on: [compile-gke]
container:
image: ${{ inputs.builder_image }}
env:
JOB_CACHE_PREFIX: gasp-node-unit-tests-cache-${{ inputs.cache-version }}
CACHE_ARCHIVE_NAME: cache_archive.tar.zst
steps:
- uses: actions/checkout@v4
- uses: google-github-actions/auth@v2
id: auth
with:
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
- uses: google-github-actions/setup-gcloud@v2

- name: Download cargo build cache
if: inputs.cache-enabled
id: cache
run: |
set -x
CACHE_KEY="${{ env.JOB_CACHE_PREFIX }}-${{ hashFiles('**/Cargo.lock') }}"
ARCHIVE_NAME="${{ env.CACHE_ARCHIVE_NAME }}"
CACHE_FOUND=false
if gcloud storage cp "gs://mangata-node-ci-cache/$CACHE_KEY/$ARCHIVE_NAME" - | zstd -d | tar -xf - -C / ; then
CACHE_FOUND=true
fi
echo "cache_found=$CACHE_FOUND" >> $GITHUB_OUTPUT
echo "cache_key=$CACHE_KEY" >> $GITHUB_OUTPUT
- name: Install sccache-cache only on non-release runs
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
uses: mozilla-actions/[email protected]
- name: Set Rust caching env vars only on non-release run
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
run: |
echo "SCCACHE_GCS_BUCKET=mangata-node-ci-cache" >> $GITHUB_ENV
echo "SCCACHE_GCS_RW_MODE=READ_WRITE" >> $GITHUB_ENV
echo "SCCACHE_GCS_KEY_PREFIX=${{ env.JOB_CACHE_PREFIX }}" >> $GITHUB_ENV
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
echo "CARGO_INCREMENTAL=0" >> $GITHUB_ENV
- name: Run unit tests
run: cargo test -j2

- name: Upload cargo build cache
if: inputs.cache-enabled && steps.cache.outputs.cache_found == 'false'
shell: bash
run: |
set -x
CACHE_KEY="${{ steps.cache.outputs.cache_key }}"
ARCHIVE_NAME="${{ env.CACHE_ARCHIVE_NAME }}"
CACHE_PATHS=(
"./target"
"/usr/local/cargo/bin/"
"/usr/local/cargo/registry/index/"
"/usr/local/cargo/registry/cache/"
"/usr/local/cargo/git/db/"
)
SECONDS=0; tar -cf - "${CACHE_PATHS[@]}" | zstd -T0 -5 > "$ARCHIVE_NAME"
echo "Compression completed in $SECONDS seconds" && echo "Archive size: $(du -h "$ARCHIVE_NAME" | cut -f1)"
SECONDS=0; gcloud storage cp "$ARCHIVE_NAME" "gs://mangata-node-ci-cache/$CACHE_KEY/$ARCHIVE_NAME"
echo "Upload completed in $SECONDS seconds"
- name: Fix permissions on self-hosted runner
if: always()
run: chown -R 1100:1100 $GITHUB_WORKSPACE

coverage-report:
name: '[gasp-node] Coverage report'
runs-on: [compile-gke]
container:
image: ${{ inputs.builder_image }}
options: --security-opt seccomp=unconfined
env:
JOB_CACHE_PREFIX: gasp-node-coverage-job-cache-${{ inputs.cache-version }}
CACHE_ARCHIVE_NAME: cache_archive.tar.zst
steps:
- uses: actions/checkout@v4
- uses: google-github-actions/auth@v2
id: auth
with:
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
- uses: google-github-actions/setup-gcloud@v2

- name: Download cargo build cache
if: inputs.cache-enabled
id: cache
run: |
set -x
CACHE_KEY="${{ env.JOB_CACHE_PREFIX }}-${{ hashFiles('**/Cargo.lock') }}"
ARCHIVE_NAME="${{ env.CACHE_ARCHIVE_NAME }}"
CACHE_FOUND=false
if gcloud storage cp "gs://mangata-node-ci-cache/$CACHE_KEY/$ARCHIVE_NAME" - | zstd -d | tar -xf - -C / ; then
CACHE_FOUND=true
fi
echo "cache_found=$CACHE_FOUND" >> $GITHUB_OUTPUT
echo "cache_key=$CACHE_KEY" >> $GITHUB_OUTPUT
- name: Install sccache-cache only on non-release runs
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
uses: mozilla-actions/[email protected]
- name: Set Rust caching env vars only on non-release run
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
run: |
echo "SCCACHE_GCS_BUCKET=mangata-node-ci-cache" >> $GITHUB_ENV
echo "SCCACHE_GCS_RW_MODE=READ_WRITE" >> $GITHUB_ENV
echo "SCCACHE_GCS_KEY_PREFIX=${{ env.JOB_CACHE_PREFIX }}" >> $GITHUB_ENV
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
echo "CARGO_INCREMENTAL=0" >> $GITHUB_ENV
- name: Install cargo-tarpaulin
run: cargo install [email protected] --locked --force
- name: Generate coverage report with cargo-tarpaulin
run: cargo tarpaulin --timeout 120 --workspace -e rollup-runtime-integration-test rollup-node rollup-runtime --exclude-files **/mock.rs **/weights.rs **/weights/* --out Xml
- name: Upload to codecov.io
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.ORG_CODECOV_TOKEN }}
fail_ci_if_error: false

- name: Upload cargo build cache
if: inputs.cache-enabled && steps.cache.outputs.cache_found == 'false'
shell: bash
run: |
set -x
CACHE_KEY="${{ steps.cache.outputs.cache_key }}"
ARCHIVE_NAME="${{ env.CACHE_ARCHIVE_NAME }}"
CACHE_PATHS=(
"./target"
"/usr/local/cargo/bin/"
"/usr/local/cargo/registry/index/"
"/usr/local/cargo/registry/cache/"
"/usr/local/cargo/git/db/"
)
SECONDS=0; tar -cf - "${CACHE_PATHS[@]}" | zstd -T0 -5 > "$ARCHIVE_NAME"
echo "Compression completed in $SECONDS seconds" && echo "Archive size: $(du -h "$ARCHIVE_NAME" | cut -f1)"
SECONDS=0; gcloud storage cp "$ARCHIVE_NAME" "gs://mangata-node-ci-cache/$CACHE_KEY/$ARCHIVE_NAME"
echo "Upload completed in $SECONDS seconds"
- name: Fix permissions on self-hosted runner
if: always()
run: chown -R 1100:1100 $GITHUB_WORKSPACE

run-benchmarks-tests:
name: '[gasp-node] Run benchmark tests'
runs-on: ubuntu-24.04
Expand Down Expand Up @@ -891,16 +736,4 @@ jobs:
- name: Fix permissions on self-hosted runner
if: always()
run: chown -R 1100:1100 $GITHUB_WORKSPACE

run-e2e-test-gasp-node:
name: '[gasp-node] Run e2e tests'
needs: [create-docker-image-manifest-and-export-wasms, create-fast-docker-image-manifest-and-export-wasms, create-unlocked-runtime-docker-image-manifest-and-export-wasms]
uses: ./.github/workflows/reusable-gasp-node-e2e-tests.yml
secrets: inherit
permissions:
contents: read
actions: read
checks: write
with:
globalVersion: ${{ inputs.version }}
run: chown -R 1100:1100 $GITHUB_WORKSPACE
Loading

0 comments on commit b22c7ad

Please sign in to comment.