From 7192b9b748b9aa0d37a817e99025a4aaff9a2913 Mon Sep 17 00:00:00 2001 From: Florian Franzen Date: Sat, 29 Jun 2024 23:47:06 +0200 Subject: [PATCH] ci: cleanup and reorg all workflows --- .github/actions/cargo-command/action.yaml | 55 +++++++ .github/actions/rust-init/action.yaml | 14 -- .github/workflows/benchmark.yaml | 53 ------- .github/workflows/build-chronicle.yaml | 65 -------- .github/workflows/build-docs.yaml | 30 ---- .github/workflows/build-node.yaml | 79 ---------- .github/workflows/build-runtime.yaml | 123 --------------- .github/workflows/build-tester.yaml | 64 -------- .github/workflows/deploy-cluster.yaml | 84 ---------- .github/workflows/deploy-docker.yaml | 51 ------ ...eploy-docs.yaml => merge-deploy-docs.yaml} | 24 ++- ...nicle.yaml => merge-docker-chronicle.yaml} | 34 ++-- ...r-tester.yaml => merge-docker-tester.yaml} | 16 +- ...menode.yaml => merge-docker-timenode.yaml} | 27 ++-- ...runtime.yaml => merge-srtool-runtime.yaml} | 14 +- .github/workflows/pr-build-chronicle.yaml | 41 +++++ .github/workflows/pr-build-docs.yaml | 37 +++++ .github/workflows/pr-build-node.yaml | 44 ++++++ .github/workflows/pr-build-runtime.yaml | 88 +++++++++++ .github/workflows/pr-build-tester.yaml | 40 +++++ .github/workflows/pr-test-audit.yaml | 24 +++ .github/workflows/pr-test-basic.yaml | 26 ++++ .github/workflows/pr-test-cargo.yaml | 47 ++++++ .github/workflows/pr-test-codecov.yaml | 27 ++++ .github/workflows/pr-test-rustfmt.yaml | 30 ++++ .github/workflows/pr-update-benchmarks.yaml | 24 +++ .github/workflows/self-hosted.yml | 146 ------------------ .github/workflows/test.yaml | 44 ------ 28 files changed, 536 insertions(+), 815 deletions(-) create mode 100644 .github/actions/cargo-command/action.yaml delete mode 100644 .github/actions/rust-init/action.yaml delete mode 100644 .github/workflows/benchmark.yaml delete mode 100644 .github/workflows/build-chronicle.yaml delete mode 100644 .github/workflows/build-docs.yaml delete mode 100644 .github/workflows/build-node.yaml delete mode 100644 .github/workflows/build-runtime.yaml delete mode 100644 .github/workflows/build-tester.yaml delete mode 100644 .github/workflows/deploy-cluster.yaml delete mode 100644 .github/workflows/deploy-docker.yaml rename .github/workflows/{deploy-docs.yaml => merge-deploy-docs.yaml} (66%) rename .github/workflows/{build-docker-chronicle.yaml => merge-docker-chronicle.yaml} (81%) rename .github/workflows/{build-docker-tester.yaml => merge-docker-tester.yaml} (95%) rename .github/workflows/{build-docker-timenode.yaml => merge-docker-timenode.yaml} (84%) rename .github/workflows/{build-srtool-runtime.yaml => merge-srtool-runtime.yaml} (93%) create mode 100644 .github/workflows/pr-build-chronicle.yaml create mode 100644 .github/workflows/pr-build-docs.yaml create mode 100644 .github/workflows/pr-build-node.yaml create mode 100644 .github/workflows/pr-build-runtime.yaml create mode 100644 .github/workflows/pr-build-tester.yaml create mode 100644 .github/workflows/pr-test-audit.yaml create mode 100644 .github/workflows/pr-test-basic.yaml create mode 100644 .github/workflows/pr-test-cargo.yaml create mode 100644 .github/workflows/pr-test-codecov.yaml create mode 100644 .github/workflows/pr-test-rustfmt.yaml create mode 100644 .github/workflows/pr-update-benchmarks.yaml delete mode 100644 .github/workflows/self-hosted.yml delete mode 100644 .github/workflows/test.yaml diff --git a/.github/actions/cargo-command/action.yaml b/.github/actions/cargo-command/action.yaml new file mode 100644 index 000000000..65a452b63 --- /dev/null +++ b/.github/actions/cargo-command/action.yaml @@ -0,0 +1,55 @@ +name: "Setup, cache and execute cargo command" +description: "Install dependencies, rust, cache in- and outputs and run cargo command." +inputs: + command: + description: 'Cargo command to run' + required: false + default: 'build' + package: + description: 'Limit execution to a specific package' + required: false + profile: + description: 'Profile under which to run cargo command' + required: false + default: 'release' + features: + description: 'Feature with which to run cargo command' + required: false + args: + description: 'Additional argument to pass to cargo invocation' + required: false +runs: + using: "composite" + steps: + - name: Install rust toolchain + shell: bash + run : rustup show + - name: Clear cargo registry and index + shell: bash + run: rm -rf ~/.cargo/registry ~/.cargo/git + - name: Cache cargo registry and index + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + key: cargo-cache-${{ inputs.package || 'workspace' }}-${{ inputs.features || 'default' }}-${{ hashFiles('Cargo.lock') }} + restore-keys: | + cargo-cache-${{ inputs.package || 'workspace' }}-${{ inputs.features || 'default' }}- + cargo-cache-${{ inputs.package || 'workspace' }}-default- + cargo-cache-workspace- + - name: Cache cargo target folder + uses: actions/cache@v4 + with: + path: target + key: cargo-${{ inputs.command }}-${{ inputs.profile }}-${{ inputs.package || 'workspace' }}-${{ inputs.features || 'default' }}-${{ hashFiles('Cargo.lock') }} + restore-keys: | + cargo-${{ inputs.command }}-${{ inputs.profile }}-${{ inputs.package || 'workspace' }}-${{ inputs.features || 'default' }}- + cargo-${{ inputs.command }}-${{ inputs.profile }}-${{ inputs.package || 'workspace' }}-default- + cargo-${{ inputs.command }}-${{ inputs.profile }}-workspace- + - name: Run cargo ${{ inputs.command }} + env: + CARGO_TERM_COLOR: always + shell: bash + run: cargo ${{ inputs.command }} ${{ inputs.package != '' && '--package' || '' }} ${{ inputs.package }} --profile '${{ inputs.profile }}' --features '${{ inputs.features }}' ${{ inputs.args }} diff --git a/.github/actions/rust-init/action.yaml b/.github/actions/rust-init/action.yaml deleted file mode 100644 index b765e52f1..000000000 --- a/.github/actions/rust-init/action.yaml +++ /dev/null @@ -1,14 +0,0 @@ -name: "Init Rust" -description: "Install Rust version with Timechain dependencies" - -inputs: {} - -runs: - using: "composite" - steps: - - name: Install dependencies - shell: bash - run: sudo apt-get update && sudo apt-get install -y protobuf-compiler - - name: Install rust toolchain - shell: bash - run : rustup show \ No newline at end of file diff --git a/.github/workflows/benchmark.yaml b/.github/workflows/benchmark.yaml deleted file mode 100644 index 323537d4f..000000000 --- a/.github/workflows/benchmark.yaml +++ /dev/null @@ -1,53 +0,0 @@ -########################################################## -# -# Workflow for running benchmarks on the self-hosted -# benchmark machine. -# -# Workflow is triggered on each pull request with -# label `!ci-benchmark` and skip all files that aren't -# related to the pallets, runtime or node. -# -# After weights are generated, the CI commits and pushes -# the weights.rs files to the PR's branch. -# -########################################################## - -name: Run benchmarks - -on: - pull_request: - paths-ignore: - - 'docker/**' - - 'docs/**' - - 'infra/**' - - 'js/**' - - '**/*.md' - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - run-benchmarks: - runs-on: [self-hosted, benchmark] - if: ${{ - github.event_name == 'push' || - contains(github.event.pull_request.labels.*.name,'!ci-benchmark') - }} - steps: - - name: Checkout sources - uses: actions/checkout@v3 - with: - repository: ${{ github.event.pull_request.head.repo.full_name }} - ref: ${{ github.event.pull_request.head.ref }} - - name: Install protobuf - run: sudo apt update && sudo apt install -y protobuf-compiler - - name: Run benchmark script - run: ./scripts/benchmarking.sh - - name: Commit weights - uses: EndBug/add-and-commit@v9 - with: - add: './runtime/src/weights' - default_author: github_actions - author_name: Github Actions - message: 'Add generated weights' diff --git a/.github/workflows/build-chronicle.yaml b/.github/workflows/build-chronicle.yaml deleted file mode 100644 index ef422dafe..000000000 --- a/.github/workflows/build-chronicle.yaml +++ /dev/null @@ -1,65 +0,0 @@ -name: Compile chronicle - -on: - pull_request: - paths-ignore: - - 'contracts/**' - - 'docker/**' - - 'docs/**' - - 'node/**' - - 'infra/**' - - 'js/**' - - 'scripts/**' - - 'tester/**' - - 'utils/**' - - '**/*.md' - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - build-chronicle: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - profile: - - production - - testnet - steps: - - name: Install dependencies - run: sudo apt-get update && sudo apt-get install -y musl-tools protobuf-compiler - - name: Checkout sources - uses: actions/checkout@v4 - with: - submodules: recursive - - name: Install rust toolchain - run : rustup show - - name: Setup and cache sccache - uses: visvirial/sccache-action@v1.0.1 - with: - cache-key: sccache-chronicle-${{ matrix.profile }} - - name: Cache cargo registry and index - uses: actions/cache@v4 - with: - path: | - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - key: cargo-cache-chronicle-${{ hashFiles('Cargo.lock') }} - restore-keys: cargo-cache-chronicle- - - name: Cache cargo build output - uses: actions/cache@v4 - with: - path: target - key: cargo-build-chronicle-${{ matrix.profile }}-${{ hashFiles('Cargo.lock') }} - restore-keys: cargo-build-chronicle-${{ matrix.profile }}- - - name: Build chronicle - run: cargo build --package chronicle --profile ${{ matrix.profile }} - - name: Upload chronicle - uses: actions/upload-artifact@v4 - with: - name: chronicle.${{ matrix.profile }} - if-no-files-found: error - path: target/${{ matrix.profile }}/chronicle diff --git a/.github/workflows/build-docs.yaml b/.github/workflows/build-docs.yaml deleted file mode 100644 index 7cc13a3a8..000000000 --- a/.github/workflows/build-docs.yaml +++ /dev/null @@ -1,30 +0,0 @@ -name: Generate docs - -on: - pull_request: - paths-ignore: - - 'docker/**' - - 'infra/**' - - 'js/**' - - 'scripts/**' - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - build-docs: - runs-on: ubuntu-latest - steps: - - name: Checkout sources - uses: actions/checkout@v4 - - name: Initialize Rust - uses: ./.github/actions/rust-init - - name: Build docs - run: cargo doc --no-deps --document-private-items --workspace - - name: Upload docs - uses: actions/upload-artifact@v4 - with: - name: docs - if-no-files-found: error - path: target/doc diff --git a/.github/workflows/build-node.yaml b/.github/workflows/build-node.yaml deleted file mode 100644 index 7a7a573b6..000000000 --- a/.github/workflows/build-node.yaml +++ /dev/null @@ -1,79 +0,0 @@ -name: Compile node - -on: - pull_request: - paths-ignore: - - 'chronicle/**' - - 'contracts/**' - - 'docker/**' - - 'docs/**' - - 'infra/**' - - 'js/**' - - 'lib/**' - - 'scripts/**' - - 'tc-subxt/**' - - 'tester/**' - - 'tss/**' - - 'utils/**' - - '**/*.md' - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - setup: - runs-on: [ self-hosted-timechain ] - steps: - - name: Install rust toolchain - run : rustup show - - name: Checkout sources - uses: actions/checkout@v4 - with: - ref: ${{ github.event.pull_request.head.sha }} - submodules: recursive - - name: Cache cargo registry and index - uses: actions/cache@v4 - with: - path: | - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - key: cargo-cache-timechain-${{ hashFiles('Cargo.lock') }} - restore-keys: cargo-cache-timechain- - - build-node: - runs-on: [ self-hosted-timechain ] - needs: [ setup ] - strategy: - fail-fast: false - matrix: - include: - - profile: production - features: default - - profile: testnet - features: default - - profile: testnet - features: development - steps: - - name: Checkout sources - uses: actions/checkout@v4 - with: - ref: ${{ github.event.pull_request.head.sha }} - submodules: recursive - - name: Cache cargo build output - uses: actions/cache@v4 - with: - path: target - key: cargo-build-timenode-${{ matrix.profile }}-${{ hashFiles('Cargo.lock') }} - restore-keys: cargo-build-timenode-${{ matrix.profile }}- - - name: Build timechain node - env: - SKIP_WASM_BUILD: true - run: cargo build --package timechain-node --profile ${{ matrix.profile }} --features ${{ matrix.features }} - - name: Upload timechain node - uses: actions/upload-artifact@v4 - with: - name: timenode.${{ matrix.profile }}.${{ matrix.features }} - if-no-files-found: error - path: target/${{ matrix.profile }}/timechain-node diff --git a/.github/workflows/build-runtime.yaml b/.github/workflows/build-runtime.yaml deleted file mode 100644 index e21f0d140..000000000 --- a/.github/workflows/build-runtime.yaml +++ /dev/null @@ -1,123 +0,0 @@ -name: Compile runtimes - -on: - pull_request: - paths-ignore: - - 'chronicle/**' - - 'contracts/**' - - 'docker/**' - - 'docs/**' - - 'infra/**' - - 'js/**' - - 'lib/**' - - 'scripts/**' - - 'tc-subxt/**' - - 'tester/**' - - 'tss/**' - - 'utils/**' - - '**/*.md' - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - setup: - runs-on: [ self-hosted-timechain ] - steps: - - name: Install rust toolchain - run : rustup show - - name: Checkout sources - uses: actions/checkout@v4 - with: - ref: ${{ github.event.pull_request.head.sha }} - submodules: recursive - - name: Cache cargo registry and index - uses: actions/cache@v4 - with: - path: | - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - key: cargo-cache-timechain-${{ hashFiles('Cargo.lock') }} - restore-keys: cargo-cache-timechain- - - build-runtime: - runs-on: [ self-hosted-timechain ] - needs: [ setup ] - strategy: - fail-fast: false - matrix: - include: - - package: timechain-runtime - features: default - crate: timechain_runtime - - package: timechain-runtime - features: development - crate: timechain_runtime - steps: - - name: Checkout sources - uses: actions/checkout@v4 - with: - ref: ${{ github.event.pull_request.head.sha }} - submodules: recursive - - name: Cache cargo build output - uses: actions/cache@v4 - with: - path: target - key: cargo-build-${{ matrix.package }}-${{ matrix.features }}-${{ hashFiles('Cargo.lock') }} - restore-keys: cargo-build-${{ matrix.package }}-${{ matrix.features }}- - - name: Build timechain runtime - run: cargo build --package ${{ matrix.package }} --profile release --features ${{ matrix.features }} - - name: Upload timechain runtime - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.package }}.${{ matrix.features }}.wasm - if-no-files-found: error - path: target/release/wbuild/${{ matrix.package }}/${{ matrix.crate }}.compact.compressed.wasm - - name: Upload timechain metadata - uses: actions/upload-artifact@v4 - with: - name: ${{ matrix.package }}.${{ matrix.features }}.scale - if-no-files-found: error - path: target/release/wbuild/${{ matrix.package }}/${{ matrix.crate }}.metadata.scale - - update-metadata: - runs-on: [ self-hosted-timechain ] - needs: [ build-runtime ] - if: ${{ always() }} - continue-on-error: true - steps: - - name: Checkout sources - uses: actions/checkout@v4 - with: - ref: ${{ github.head_ref }} - submodules: recursive - - name: Download and update Testnet Metadata - id: download-testnet-default-metadata - uses: actions/download-artifact@v4 - continue-on-error: true - with: - name: timechain-runtime.default.scale - - name: Download and Testnet Metadata - if: steps.download-testnet-default-metadata.outcome == 'success' - run: mv timechain_runtime.metadata.scale config/subxt/testnet.default.scale - - name: Download Development Metadata - id: download-testnet-development-metadata - uses: actions/download-artifact@v4 - continue-on-error: true - with: - name: timechain-runtime.development.scale - - name: Update Development Metadata - if: steps.download-testnet-development-metadata.outcome == 'success' - run: mv timechain_runtime.metadata.scale config/subxt/testnet.development.scale - - name: Commit any changes to the metadata - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - if ! git diff --quiet; then - git config user.email "github@analog.one" - git config user.name "Metadata Update Bot" - git commit -am "tc-subxt: Automated metadata update" - git push - fi diff --git a/.github/workflows/build-tester.yaml b/.github/workflows/build-tester.yaml deleted file mode 100644 index 490bd1667..000000000 --- a/.github/workflows/build-tester.yaml +++ /dev/null @@ -1,64 +0,0 @@ -name: Compile tester - -on: - pull_request: - paths-ignore: - - 'chronicle/**' - - 'docker/**' - - 'docs/**' - - 'infra/**' - - 'js/**' - - 'lib/**' - - 'scripts/**' - - 'utils/**' - - '**/*.md' - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - build-tester: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - profile: - - production - - testnet - steps: - - name: Install dependencies - run: sudo apt-get update && sudo apt-get install -y musl-tools protobuf-compiler - - name: Checkout sources - uses: actions/checkout@v4 - with: - submodules: recursive - - name: Install rust toolchain - run : rustup show - - name: Setup and cache sccache - uses: visvirial/sccache-action@v1.0.1 - with: - cache-key: sccache-tester-${{ matrix.profile }} - - name: Cache cargo registry and index - uses: actions/cache@v4 - with: - path: | - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - key: cargo-cache-tester-${{ hashFiles('Cargo.lock') }} - restore-keys: cargo-cache-tester- - - name: Cache cargo build output - uses: actions/cache@v4 - with: - path: target - key: cargo-build-tester-${{ matrix.profile }}-${{ hashFiles('Cargo.lock') }} - restore-keys: cargo-build-tester-${{ matrix.profile }}- - - name: Build tester - run: cargo build --package tester --profile ${{ matrix.profile }} - - name: Upload tester - uses: actions/upload-artifact@v4 - with: - name: tester.${{ matrix.profile }} - if-no-files-found: error - path: target/${{ matrix.profile }}/tester diff --git a/.github/workflows/deploy-cluster.yaml b/.github/workflows/deploy-cluster.yaml deleted file mode 100644 index 24c46d75c..000000000 --- a/.github/workflows/deploy-cluster.yaml +++ /dev/null @@ -1,84 +0,0 @@ -######################################################### -# -# Deploy to cluster workflow uses kubectl -# to patch the deployment on the cluster. -# -# Inputs: -# - version - Docker tag of the timechain image -# - environment - Env to use the configuration from -# (repo > Settings > Environments) -# -######################################################### -name: Deploy to Kubernetes cluster - -on: - workflow_dispatch: - inputs: - version: - description: "Docker image tag to deploy on the network" - required: true - type: string - environment: - description: "Target environment where to fetch secrets and vars" - required: true - type: choice - options: - - "internal" - -env: - DOCKER_REPO: analoglabs/timechain - -jobs: - deploy: - name: Deploy to K8s cluster - runs-on: ubuntu-latest - environment: ${{ github.event.inputs.environment }} - - steps: - - name: Checkout - uses: actions/checkout@v2 - - # EKS supports only authentication via IAM roles - # The AWS cli tool is mandatory - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: us-east-1 - - - name: Install AWS CLI - uses: unfor19/install-aws-cli-action@v1 - with: - version: 2 - verbose: false - arch: amd64 - rootdir: "" - workdir: "" - - # Make sure to have kubectl and the kubeconfig from the secrets - - name: Install and configure kubectl - run: | - curl https://storage.googleapis.com/kubernetes-release/release/v1.27.3/bin/linux/amd64/kubectl \ - --progress-bar \ - --location \ - --remote-name - chmod +x kubectl - sudo mv kubectl /usr/local/bin/ - echo '${{ secrets.KUBECONFIG }}' > kubeconfig.yaml - - # Using "kubectl patch" updates validator versions one by one - - name: Update validators - run: | - export KUBECONFIG=kubeconfig.yaml - IMAGE="${{ env.DOCKER_REPO }}:${{ github.event.inputs.version }}" - nodes=$(kubectl get sts -l app=timenode -o=jsonpath='{.items[*].metadata.name}') - echo "Update node version to $IMAGE"; - - sleep 10; - for node in $nodes; do - echo "Updating $node image to $IMAGE"; - kubectl patch statefulset $node --type='json' -p='[{"op": "replace", "path": "/spec/template/spec/containers/0/image", "value":"'$IMAGE'"}]' - sleep 30; - # TODO: health check for pods would be super nice - done \ No newline at end of file diff --git a/.github/workflows/deploy-docker.yaml b/.github/workflows/deploy-docker.yaml deleted file mode 100644 index 119a78d1e..000000000 --- a/.github/workflows/deploy-docker.yaml +++ /dev/null @@ -1,51 +0,0 @@ -name: Deploy Docker images - -on: - workflow_dispatch: - inputs: - version: - description: "Docker image tag to deploy on the network" - required: true - type: string - environment: - description: "Target environment where to fetch secrets and vars" - required: true - type: string - default: "internal-testnet" - -env: - DOCKER_REPO: analoglabs/timechain - CHAIN: "local" - BOOTNODE_IP: "" - -jobs: - run-ansible: - name: Run Ansible playbook - runs-on: ubuntu-latest - environment: ${{ github.event.inputs.environment }} - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Install Ansible - run: | - curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py - python3 get-pip.py - python3 -m pip install ansible - pip install docker - - name: Run playbook - uses: dawidd6/action-ansible-playbook@v2 - with: - directory: ./infra/deployment/ansible - playbook: deploy-validators.yaml - key: ${{ secrets.SSH_PRIVATE_KEY }} - inventory: | - ${{ vars.INVENTORY }} - options: | - --extra-vars "tag=${{ github.event.inputs.version }}" - --extra-vars "db_url=${{ secrets.DB_URL }}" - --extra-vars "bootnode_key=${{ secrets.BOOTNODE_KEY }}" - --extra-vars "bootnode_ip=${{ vars.BOOTNODE_IP }}" - --extra-vars "chain=${{ vars.CHAIN }}" - --extra-vars "node_key=${{ secrets.NODE_KEY }}" - --verbose - \ No newline at end of file diff --git a/.github/workflows/deploy-docs.yaml b/.github/workflows/merge-deploy-docs.yaml similarity index 66% rename from .github/workflows/deploy-docs.yaml rename to .github/workflows/merge-deploy-docs.yaml index 46d22c2ea..e48481887 100644 --- a/.github/workflows/deploy-docs.yaml +++ b/.github/workflows/merge-deploy-docs.yaml @@ -1,11 +1,18 @@ name: Generate docs on: push: - paths-ignore: - - 'docker/**' - - 'infra/**' - - 'js/**' - - 'scripts/**' + paths: + - 'chronicle/**' + - 'config/subxt/**' + - 'docs/**' + - 'lib/**' + - 'node/**' + - 'pallets/**' + - 'primitives/**' + - 'runtime/**' + - 'tc-subxt/**' + - 'tss/**' + - 'rust-toolchain.toml' branches: - 'development' permissions: @@ -21,10 +28,11 @@ jobs: steps: - name: Checkout sources uses: actions/checkout@v4 - - name: Initialize Rust - uses: ./.github/actions/rust-init - name: Build docs - run: cargo doc --no-deps --document-private-items --workspace + uses: ./.github/actions/cargo-command + with: + command: doc + args: --workspace --no-deps --document-private-items - name: Assemble structure env: DOCS_HIDEOUT: an8ohgahmoot6ro8ieReib9micau0Oow diff --git a/.github/workflows/build-docker-chronicle.yaml b/.github/workflows/merge-docker-chronicle.yaml similarity index 81% rename from .github/workflows/build-docker-chronicle.yaml rename to .github/workflows/merge-docker-chronicle.yaml index f0d073ecb..2119a1786 100644 --- a/.github/workflows/build-docker-chronicle.yaml +++ b/.github/workflows/merge-docker-chronicle.yaml @@ -1,24 +1,23 @@ name: Build Docker chronicle image - on: push: - paths-ignore: - - 'contracts/**' - - '**/*.md' - - 'scripts/**' - - 'utils/**' - - 'tester/**' - - 'node/**' + paths: + - 'chronicle/**' + - 'config/subxt/**' + - 'lib/**' + - 'primitives/**' + - 'tc-subxt/**' + - 'tss/**' + - 'Cargo.toml' + - 'Cargo.lock' + - 'rust-toolchain.toml' branches: - 'development' - concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true - env: DOCKER_REPO: analoglabs/chronicle - jobs: set-tags: name: Get & set tags @@ -36,7 +35,6 @@ jobs: echo "sha=$sha" >> $GITHUB_OUTPUT echo "sha8=$(git log -1 --format='%H' | cut -c1-8)" >> $GITHUB_OUTPUT echo "SHA commit:" $sha - build-binary: name: Build Docker image needs: ["set-tags"] @@ -45,10 +43,10 @@ jobs: fail-fast: false matrix: include: - - image: prod - profile: production - - image: dev - profile: testnet + - image: prod + profile: production + - image: dev + profile: testnet steps: - name: Fetch latest code uses: actions/checkout@v3 @@ -70,6 +68,6 @@ jobs: ${{ env.DOCKER_REPO }}-${{ matrix.image }}:${{ needs.set-tags.outputs.commit_hash8 }} ${{ env.DOCKER_REPO }}:latest file: config/docker/Dockerfile.chronicle-release - build-args: | + build-args: |- VCS_REF=${{ needs.set-tags.outputs.commit_hash8 }} - PROFILE=${{ matrix.profile }} \ No newline at end of file + PROFILE=${{ matrix.profile }} diff --git a/.github/workflows/build-docker-tester.yaml b/.github/workflows/merge-docker-tester.yaml similarity index 95% rename from .github/workflows/build-docker-tester.yaml rename to .github/workflows/merge-docker-tester.yaml index f193ebd43..9a222fb7f 100644 --- a/.github/workflows/build-docker-tester.yaml +++ b/.github/workflows/merge-docker-tester.yaml @@ -7,27 +7,24 @@ # ########################################################## name: Build Docker tester image - on: push: paths: - - 'tester/**' + - 'analog-gmp/**' + - 'config/subxt/**' - 'primitives/**' - 'tc-subxt/**' - - 'contracts/**' - - 'config/**' - - 'runtime/**' - - 'pallets/**' + - 'tester/**' + - 'Cargo.toml' + - 'Cargo.lock' + - 'rust-toolchain.toml' branches: - 'development' - concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true - env: DOCKER_REPO: analoglabs/tester - jobs: set-tags: name: Get & set tags @@ -45,7 +42,6 @@ jobs: echo "sha=$sha" >> $GITHUB_OUTPUT echo "sha8=$(git log -1 --format='%H' | cut -c1-8)" >> $GITHUB_OUTPUT echo "SHA commit:" $sha - build-binary: name: Build Docker image needs: ["set-tags"] diff --git a/.github/workflows/build-docker-timenode.yaml b/.github/workflows/merge-docker-timenode.yaml similarity index 84% rename from .github/workflows/build-docker-timenode.yaml rename to .github/workflows/merge-docker-timenode.yaml index 5b8d6af0c..53af14c93 100644 --- a/.github/workflows/build-docker-timenode.yaml +++ b/.github/workflows/merge-docker-timenode.yaml @@ -1,17 +1,13 @@ name: Build Docker timechain node image - on: push: branches: - "ci/binary/**" - concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true - env: DOCKER_REPO: analoglabs/timenode - jobs: set-tags: name: Get & set tags @@ -29,7 +25,6 @@ jobs: echo "sha=$sha" >> $GITHUB_OUTPUT echo "sha8=$(git log -1 --format='%H' | cut -c1-8)" >> $GITHUB_OUTPUT echo "SHA commit:" $sha - build-binary: name: Build Docker image needs: ["set-tags"] @@ -38,15 +33,15 @@ jobs: fail-fast: false matrix: include: - - image: prod - profile: production - features: default - - image: test - profile: testnet - features: default - - image: dev - profile: testnet - features: development + - image: prod + profile: production + features: default + - image: test + profile: testnet + features: default + - image: dev + profile: testnet + features: development steps: - name: Fetch latest code uses: actions/checkout@v3 @@ -66,8 +61,8 @@ jobs: push: true tags: ${{ env.DOCKER_REPO }}-${{ matrix.image }}:${{ needs.set-tags.outputs.commit_hash8 }} file: config/docker/Dockerfile.release - build-args: | + build-args: |- VCS_REF=${{ needs.set-tags.outputs.commit_hash8 }} PROFILE=${{ matrix.profile }} FEATURES=${{ matrix.features }} - BUILD_VARIANT=${{ matrix.image }} \ No newline at end of file + BUILD_VARIANT=${{ matrix.image }} diff --git a/.github/workflows/build-srtool-runtime.yaml b/.github/workflows/merge-srtool-runtime.yaml similarity index 93% rename from .github/workflows/build-srtool-runtime.yaml rename to .github/workflows/merge-srtool-runtime.yaml index e2e195a4d..df7dae6a1 100644 --- a/.github/workflows/build-srtool-runtime.yaml +++ b/.github/workflows/merge-srtool-runtime.yaml @@ -1,10 +1,8 @@ name: Build runtime artifacts - on: push: branches: - "ci/runtime/**" - jobs: set-tags: name: Get & set tags @@ -22,7 +20,6 @@ jobs: echo "sha=$sha" >> $GITHUB_OUTPUT echo "sha8=$(git log -1 --format='%H' | cut -c1-8)" >> $GITHUB_OUTPUT echo "SHA commit:" $sha - build-runtime: name: Build runtimes needs: ["set-tags"] @@ -31,14 +28,13 @@ jobs: fail-fast: false matrix: include: - - chain: timechain - features: default - - chain: timechain - features: development + - chain: timechain + features: default + - chain: timechain + features: development steps: - name: Fetch latest code uses: actions/checkout@v3 - - name: Build timechain runtime id: srtool_build uses: chevdor/srtool-actions@v0.8.0 @@ -49,13 +45,11 @@ jobs: tag: 1.75.0 chain: ${{ matrix.chain }} runtime_dir: "runtime" - - name: Srtool summary run: | echo '${{ steps.srtool_build.outputs.json }}' | jq . > timechain-srtool-digest.json cat timechain-srtool-digest.json echo "Runtime location: ${{ steps.srtool_build.outputs.wasm_compressed }}" - - name: Upload timechain runtime artifacts uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/pr-build-chronicle.yaml b/.github/workflows/pr-build-chronicle.yaml new file mode 100644 index 000000000..7f2cc282e --- /dev/null +++ b/.github/workflows/pr-build-chronicle.yaml @@ -0,0 +1,41 @@ +name: Compile chronicle +on: + pull_request: + paths: + - 'chronicle/**' + - 'config/subxt/**' + - 'lib/**' + - 'primitives/**' + - 'tc-subxt/**' + - 'tss/**' + - 'Cargo.toml' + - 'Cargo.lock' + - 'rust-toolchain.toml' +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: + build-chronicle: + runs-on: [self-hosted, general] + strategy: + fail-fast: false + matrix: + profile: + - production + - testnet + steps: + - name: Checkout sources + uses: actions/checkout@v4 + with: + submodules: recursive + - name: Build chronicle + uses: ./.github/actions/cargo-command + with: + package: chronicle + profile: ${{ matrix.profile }} + - name: Upload chronicle + uses: actions/upload-artifact@v4 + with: + name: chronicle.${{ matrix.profile }} + if-no-files-found: error + path: target/${{ matrix.profile }}/chronicle diff --git a/.github/workflows/pr-build-docs.yaml b/.github/workflows/pr-build-docs.yaml new file mode 100644 index 000000000..04adc2d42 --- /dev/null +++ b/.github/workflows/pr-build-docs.yaml @@ -0,0 +1,37 @@ +name: Generate docs +on: + pull_request: + paths: + - 'chronicle/**' + - 'config/subxt/**' + - 'docs/**' + - 'lib/**' + - 'node/**' + - 'pallets/**' + - 'primitives/**' + - 'runtime/**' + - 'tc-subxt/**' + - 'tss/**' + - 'rust-toolchain.toml' +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: + build-docs: + runs-on: [self-hosted, general] + steps: + - name: Checkout sources + uses: actions/checkout@v4 + with: + submodules: recursive + - name: Build docs + uses: ./.github/actions/cargo-command + with: + command: doc + args: --workspace --no-deps --document-private-items + - name: Upload docs + uses: actions/upload-artifact@v4 + with: + name: docs + if-no-files-found: error + path: target/doc diff --git a/.github/workflows/pr-build-node.yaml b/.github/workflows/pr-build-node.yaml new file mode 100644 index 000000000..3819acc17 --- /dev/null +++ b/.github/workflows/pr-build-node.yaml @@ -0,0 +1,44 @@ +name: Compile node +on: + pull_request: + paths: + - 'node/**' + - 'primitives/**' + - 'Cargo.toml' + - 'Cargo.lock' + - 'rust-toolchain.toml' +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: + build-node: + runs-on: [self-hosted, general] + strategy: + fail-fast: false + matrix: + include: + - profile: production + features: default + - profile: testnet + features: default + - profile: testnet + features: development + steps: + - name: Checkout sources + uses: actions/checkout@v4 + with: + submodules: recursive + - name: Build timenode + uses: ./.github/actions/cargo-command + env: + SKIP_WASM_BUILD: true + with: + package: timechain-node + profile: ${{ matrix.profile }} + features: ${{ matrix.features }} + - name: Upload timechain node + uses: actions/upload-artifact@v4 + with: + name: timenode.${{ matrix.profile }}.${{ matrix.features }} + if-no-files-found: error + path: target/${{ matrix.profile }}/timechain-node diff --git a/.github/workflows/pr-build-runtime.yaml b/.github/workflows/pr-build-runtime.yaml new file mode 100644 index 000000000..455be45b3 --- /dev/null +++ b/.github/workflows/pr-build-runtime.yaml @@ -0,0 +1,88 @@ +name: Compile runtimes +on: + pull_request: + paths: + - 'pallets/**' + - 'primitives/**' + - 'runtime/**' + - 'Cargo.toml' + - 'Cargo.lock' + - 'rust-toolchain.toml' +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: + build-runtime: + runs-on: [self-hosted, general] + strategy: + fail-fast: false + matrix: + include: + - package: timechain-runtime + features: default + crate: timechain_runtime + - package: timechain-runtime + features: development + crate: timechain_runtime + steps: + - name: Checkout sources + uses: actions/checkout@v4 + with: + submodules: recursive + - name: Build runtime + uses: ./.github/actions/cargo-command + with: + package: ${{ matrix.package }} + profile: release + features: ${{ matrix.features }} + - name: Upload timechain runtime + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.package }}.${{ matrix.features }}.wasm + if-no-files-found: error + path: target/release/wbuild/${{ matrix.package }}/${{ matrix.crate }}.compact.compressed.wasm + - name: Upload timechain metadata + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.package }}.${{ matrix.features }}.scale + if-no-files-found: error + path: target/release/wbuild/${{ matrix.package }}/${{ matrix.crate }}.metadata.scale + update-metadata: + runs-on: [self-hosted, general] + needs: [build-runtime] + if: ${{ always() }} + continue-on-error: true + steps: + - name: Checkout sources + uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} + submodules: recursive + - name: Download and update Testnet Metadata + id: download-testnet-default-metadata + uses: actions/download-artifact@v4 + continue-on-error: true + with: + name: timechain-runtime.default.scale + - name: Download and Testnet Metadata + if: steps.download-testnet-default-metadata.outcome == 'success' + run: mv timechain_runtime.metadata.scale config/subxt/testnet.default.scale + - name: Download Development Metadata + id: download-testnet-development-metadata + uses: actions/download-artifact@v4 + continue-on-error: true + with: + name: timechain-runtime.development.scale + - name: Update Development Metadata + if: steps.download-testnet-development-metadata.outcome == 'success' + run: mv timechain_runtime.metadata.scale config/subxt/testnet.development.scale + - name: Commit any changes to the metadata + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + if ! git diff --quiet; then + git config user.email "github@analog.one" + git config user.name "Metadata Update Bot" + git commit -am "tc-subxt: Automated metadata update" + git push + fi diff --git a/.github/workflows/pr-build-tester.yaml b/.github/workflows/pr-build-tester.yaml new file mode 100644 index 000000000..395133262 --- /dev/null +++ b/.github/workflows/pr-build-tester.yaml @@ -0,0 +1,40 @@ +name: Compile tester +on: + pull_request: + paths: + - 'analog-gmp/**' + - 'config/subxt/**' + - 'primitives/**' + - 'tc-subxt/**' + - 'tester/**' + - 'Cargo.toml' + - 'Cargo.lock' + - 'rust-toolchain.toml' +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: + build-tester: + runs-on: [self-hosted, general] + strategy: + fail-fast: false + matrix: + profile: + - production + - testnet + steps: + - name: Checkout sources + uses: actions/checkout@v4 + with: + submodules: recursive + - name: Build timenode + uses: ./.github/actions/cargo-command + with: + package: tester + profile: ${{ matrix.profile }} + - name: Upload tester + uses: actions/upload-artifact@v4 + with: + name: tester.${{ matrix.profile }} + if-no-files-found: error + path: target/${{ matrix.profile }}/tester diff --git a/.github/workflows/pr-test-audit.yaml b/.github/workflows/pr-test-audit.yaml new file mode 100644 index 000000000..092b0eeb5 --- /dev/null +++ b/.github/workflows/pr-test-audit.yaml @@ -0,0 +1,24 @@ +# Triggered via !ci-audit tag +name: Test with cargo audit +on: pull_request +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: + test-audit: + runs-on: [self-hosted, general] + if: ${{ contains(github.event.pull_request.labels.*.name,'!ci-audit') }} + steps: + - name: Checkout sources + uses: actions/checkout@v4 + with: + submodules: recursive + - name: Install cargo audit + run: cargo install cargo-audit --locked + - name: Run cargo audit + run: | + $r = (cargo audit -q --json | ConvertFrom-Json) + $e = $? + $r.vulnerabilities.list | Select-Object -ExpandProperty Advisory + if (!$e) { exit 1 } + shell: pwsh diff --git a/.github/workflows/pr-test-basic.yaml b/.github/workflows/pr-test-basic.yaml new file mode 100644 index 000000000..e627138cc --- /dev/null +++ b/.github/workflows/pr-test-basic.yaml @@ -0,0 +1,26 @@ +# Triggered via !ci-test-basic tag +name: Run docker compose +on: pull_request +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: + test-basic: + runs-on: [self-hosted, general] + if: ${{ contains(github.event.pull_request.labels.*.name,'!ci-test-basic') }} + steps: + - name: Checkout sources + uses: actions/checkout@v3 + with: + submodules: recursive + - name: Refresh local deployment + run: | + docker compose --profile ethereum down -v + docker compose --profile astar down -v + ./scripts/build_docker.sh + docker compose --profile ethereum up -d + docker compose --profile astar up -d + - name: Run tester + run: | + docker compose run tester --network-id 3 --target-url ws://ethereum:8545 gmp + docker compose run tester --network-id 6 --target-url ws://astar:9944 gmp diff --git a/.github/workflows/pr-test-cargo.yaml b/.github/workflows/pr-test-cargo.yaml new file mode 100644 index 000000000..2ea6eaf40 --- /dev/null +++ b/.github/workflows/pr-test-cargo.yaml @@ -0,0 +1,47 @@ +name: Check cargo tests +on: + pull_request: + paths-ignore: + - 'chronicle/**' + - 'config/subxt/**' + - 'docs/**' + - 'node/**' + - 'pallets/**' + - 'primitives/**' + - 'runtime/**' + - 'tc-subxt/**' + - 'tester/**' + - 'tss/**' + - 'utils/**' + - 'Cargo.toml' + - 'Cargo.lock' + - 'rust-toolchain.toml' +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: + test-cargo: + runs-on: [self-hosted, general] + strategy: + fail-fast: false + matrix: + include: + - command: clippy + args: --all-targets --workspace --examples --tests -- --no-deps -D warnings + - command: test + args: --workspace --locked + - command: check + features: runtime-benchmarks + - command: check + features: try-runtime + steps: + - name: Checkout sources + uses: actions/checkout@v4 + with: + submodules: recursive + - name: Run cargo command + uses: ./.github/actions/cargo-command + with: + command: ${{ matrix.command }} + features: ${{ matrix.features }} + args: ${{ matrix.args }} diff --git a/.github/workflows/pr-test-codecov.yaml b/.github/workflows/pr-test-codecov.yaml new file mode 100644 index 000000000..80e9d52f8 --- /dev/null +++ b/.github/workflows/pr-test-codecov.yaml @@ -0,0 +1,27 @@ +# Triggered via !ci-codecov tag +name: Check code coverage +on: pull_request +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: + test-codecov: + runs-on: [self-hosted, general] + if: ${{ contains(github.event.pull_request.labels.*.name,'!ci-codecov') }} + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - name: Setup llvm-cov for cargo + uses: taiki-e/install-action@cargo-llvm-cov + - name: Unit Tests + # use --tests to measure coverage with all tests + # use --test '*' to measure coverage with integration-tests + # use --lib to measure coverage with unit-tests + run: | + cargo llvm-cov test --lib --locked --workspace --lcov --output-path lcov.info + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: lcov.info + fail_ci_if_error: true diff --git a/.github/workflows/pr-test-rustfmt.yaml b/.github/workflows/pr-test-rustfmt.yaml new file mode 100644 index 000000000..c97bdc9e9 --- /dev/null +++ b/.github/workflows/pr-test-rustfmt.yaml @@ -0,0 +1,30 @@ +name: Check code formatting +on: + pull_request: + paths: + - 'chronicle/**' + - 'docs/**' + - 'node/**' + - 'pallets/**' + - 'primitives/**' + - 'runtime/**' + - 'tc-subxt/**' + - 'tester/**' + - 'tss/**' + - 'utils/**' + - 'rustfmt.toml' +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: + test-rustfmt: + runs-on: [self-hosted, general] + steps: + - name: Checkout sources + uses: actions/checkout@v4 + with: + submodules: recursive + - name: Install rust toolchain + run : rustup show + - name: Run cargo fmt + run: cargo fmt --all -- --check diff --git a/.github/workflows/pr-update-benchmarks.yaml b/.github/workflows/pr-update-benchmarks.yaml new file mode 100644 index 000000000..26f14dc74 --- /dev/null +++ b/.github/workflows/pr-update-benchmarks.yaml @@ -0,0 +1,24 @@ +# Triggered via !ci-benchmark tag +name: Update runtime benchmarks +on: pull_request +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: + update-benchmarks: + runs-on: [self-hosted, benchmark] + if: ${{ contains(github.event.pull_request.labels.*.name,'!ci-benchmark') }} + steps: + - name: Checkout sources + uses: actions/checkout@v3 + with: + submodules: recursive + - name: Run benchmarking script + run: ./scripts/benchmarking.sh + - name: Commit updated weights + uses: EndBug/add-and-commit@v9 + with: + add: './runtime/src/weights' + default_author: github_actions + author_name: Github Actions + message: 'Add generated weights' diff --git a/.github/workflows/self-hosted.yml b/.github/workflows/self-hosted.yml deleted file mode 100644 index 952bc806c..000000000 --- a/.github/workflows/self-hosted.yml +++ /dev/null @@ -1,146 +0,0 @@ -##### -# -# when PR is updated by pushing changes to the branch -# CI skips all jobs for Drafted PRs by default -# CI skips all jobs for PRs labeled with `!ci-skip` -# -# Labels: -# !ci-draft - runs CI for drafted PR -# !ci-codecov - runs Code Coverage job on every PR update -# !ci-audit - runs Cargo Audit job on every PR update -# !ci-integration - runs Integration Tests on every PR updates -# !ci-skip - skips All jobs -# - -name: Self-Hosted -on: - push: - # yes, only trying and staging - # merging is just a setting branch head to the succeeded staging commit - # so there is no reason to execute workflow again - branches: [ trying, staging ] - pull_request: - types: [ synchronize, opened, ready_for_review, labeled, unlabeled ] - paths-ignore: - - '**/*.md' # do not run CI on pull_request update if just MD files are changed - -concurrency: - # do not run more than once for latest push/update - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -permissions: - contents: read - pull-requests: write - statuses: write - checks: write - -env: - CARGO_INCREMENTAL: 0 - CARGO_TERM_COLOR: always - -jobs: - test: - name: Build and test - runs-on: [self-hosted, rust-check] - steps: - - name: Checkout sources - uses: actions/checkout@v4 - with: - ref: ${{ github.event.pull_request.head.sha }} - submodules: recursive - - - name: Install Foundry - uses: foundry-rs/foundry-toolchain@v1 - - - run: sudo apt-get update -y - - run: sudo add-apt-repository ppa:ethereum/ethereum - - run: sudo apt-get install -y protobuf-compiler solc - - - run: forge fmt --check - - run: forge test -vvv --block-gas-limit=30000000 --optimize --optimizer-runs=200000 --evm-version=shanghai --use=0.8.25 --root analog-gmp - - - run: cargo +stable fmt --all -- --check - - run: cargo +stable test --workspace --locked - - run: cargo +stable check --features runtime-benchmarks - - run: cargo +stable check --features try-runtime - - - uses: actions-rs/clippy-check@v1 - with: - name: Clippy Report - token: ${{secrets.GITHUB_TOKEN}} - toolchain: stable - # `--no-deps` does not check dependencies out of workspace - # `--all-features` doesn't work atm - args: --all-targets --workspace --examples --tests -- --no-deps -D warnings - - audit: - name: Cargo Audit - runs-on: self-hosted - if: ${{ - github.event_name == 'push' || - contains(github.event.pull_request.labels.*.name,'!ci-codecov') - }} - env: - BUILD_OPTS: ${{needs.conditions.outputs.build-opts}} - CLIPPY_OPTS: ${{needs.conditions.outputs.clippy-opts}} - TARGET: ${{needs.conditions.outputs.target}} - WASM_BUILD_TOOLCHAIN: ${{needs.conditions.outputs.toolchain}} - RUSTUP_TOOLCHAIN: ${{needs.conditions.outputs.toolchain}} - EXCLUDE_TESTS: ${{needs.conditions.outputs.exclude-tests}} - steps: - - name: Checkout sources - uses: actions/checkout@v4 - with: - ref: ${{ github.event.pull_request.head.sha }} - - - run: cargo install cargo-audit --locked - - - name: Audit - run: | - $r = (cargo audit -q --json | ConvertFrom-Json) - $e = $? - $r.vulnerabilities.list | Select-Object -ExpandProperty Advisory - if (!$e) { exit 1 } - shell: pwsh - - code-coverage: - name: Report Code Coverage - runs-on: self-hosted - if: ${{ - github.event_name == 'push' || - contains(github.event.pull_request.labels.*.name,'!ci-audit') - }} - env: - BUILD_OPTS: ${{needs.conditions.outputs.build-opts}} - CLIPPY_OPTS: ${{needs.conditions.outputs.clippy-opts}} - TARGET: ${{needs.conditions.outputs.target}} - WASM_BUILD_TOOLCHAIN: ${{needs.conditions.outputs.toolchain}} - RUSTUP_TOOLCHAIN: ${{needs.conditions.outputs.toolchain}} - EXCLUDE_TESTS: ${{needs.conditions.outputs.exclude-tests}} - steps: - - name: Checkout sources - uses: actions/checkout@v4 - with: - ref: ${{ github.event.pull_request.head.sha }} - - - run: sudo apt-get install -y protobuf-compiler - - - name: Setup llvm-cov for cargo - uses: taiki-e/install-action@cargo-llvm-cov - - - name: Unit Tests - # use --tests to measure coverage with all tests - # use --test '*' to measure coverage with integration-tests - # use --lib to measure coverage with unit-tests - run: | - cargo llvm-cov test --lib --locked --workspace \ - --lcov --output-path lcov.info $BUILD_OPTS \ - $(for i in $EXCLUDE_TESTS; do echo "--exclude $i"; done ) - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 - with: - token: ${{ secrets.CODECOV_TOKEN }} - files: lcov.info - fail_ci_if_error: true diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml deleted file mode 100644 index 0b09ff5cd..000000000 --- a/.github/workflows/test.yaml +++ /dev/null @@ -1,44 +0,0 @@ -########################################################## -# -# Workflow for running test on the self-hosted machine. -# -# Workflow is triggered on each pull request with -# label `!ci-test-basic` -# -########################################################## - -name: Run Tests - -on: - pull_request: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - run-test: - runs-on: [self-hosted, benchmark] - if: ${{ - github.event_name == 'push' || - contains(github.event.pull_request.labels.*.name,'!ci-test-basic') - }} - steps: - - name: Checkout sources - uses: actions/checkout@v3 - with: - repository: ${{ github.event.pull_request.head.repo.full_name }} - ref: ${{ github.event.pull_request.head.ref }} - - name: Install protobuf - run: sudo apt update && sudo apt install -y protobuf-compiler - - name: Build binary - run: | - docker compose --profile ethereum down -v - docker compose --profile astar down -v - ./scripts/build_docker.sh - docker compose --profile ethereum up -d - docker compose --profile astar up -d - - name: Run test - run: | - docker compose run tester --network-id 3 --target-url ws://ethereum:8545 gmp - docker compose run tester --network-id 6 --target-url ws://astar:9944 gmp