From 1a416fa5f14a5df8c5165c358666a39119ae449f Mon Sep 17 00:00:00 2001 From: Filip Date: Fri, 18 Nov 2022 23:51:46 +0100 Subject: [PATCH] build rust with cached deps --- .github/dependabot.yml | 7 - .github/workflows/build_compile.yml | 137 ++++++++++++++++++ .github/workflows/md-link-check.yml | 19 --- .github/workflows/mlc_config.json | 7 - .../workflows/polkadot-companion-labels.yml | 32 ---- .github/workflows/release-bot.yml | 18 --- .github/workflows/trigger-review-pipeline.yml | 20 --- 7 files changed, 137 insertions(+), 103 deletions(-) delete mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/build_compile.yml delete mode 100644 .github/workflows/md-link-check.yml delete mode 100644 .github/workflows/mlc_config.json delete mode 100644 .github/workflows/polkadot-companion-labels.yml delete mode 100644 .github/workflows/release-bot.yml delete mode 100644 .github/workflows/trigger-review-pipeline.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 853c37ac15..0000000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,7 +0,0 @@ -version: 2 -updates: - - package-ecosystem: "cargo" - directory: "/" - labels: ["A2-insubstantial", "B0-silent", "C1-low 📌"] - schedule: - interval: "yearly" diff --git a/.github/workflows/build_compile.yml b/.github/workflows/build_compile.yml new file mode 100644 index 0000000000..bb4e8554b8 --- /dev/null +++ b/.github/workflows/build_compile.yml @@ -0,0 +1,137 @@ +name: Build and Check + + +on: + pull_request: + push: + branches: + - master + workflow_dispatch: + inputs: + pull_request: + description: set to pull_request number to execute on external pr + required: false + +jobs: + ####### Check files and formatting ####### + + set-tags: + runs-on: ubuntu-latest + outputs: + git_branch: ${{ steps.check-git-ref.outputs.git_branch }} + git_ref: ${{ steps.check-git-ref.outputs.git_ref }} + + check-cargo-toml-format: + name: "Check Cargo.toml files format" + runs-on: self-hosted + needs: ["set-tags"] + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + ref: ${{ needs.set-tags.outputs.git_ref }} + # With rustup's nice new toml format, we just need to run rustup show to install the toolchain + # https://github.com/actions-rs/toolchain/issues/126#issuecomment-782989659 + - name: Setup Rust toolchain + run: rustup show + - name: Check Cargo.toml files format with toml_sort + run: ./scripts/check-cargo-toml-files-format.sh + + check-rust-fmt: + name: "Check with rustfmt" + runs-on: ubuntu-latest + needs: ["set-tags"] + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + ref: ${{ needs.set-tags.outputs.git_ref }} + # With rustup's nice new toml format, we just need to run rustup show to install the toolchain + # https://github.com/actions-rs/toolchain/issues/126#issuecomment-782989659 + - name: Setup Rust toolchain + run: rustup show + - name: Format code with rustfmt + run: cargo fmt -- --check + + + cargo-clippy: + runs-on: self-hosted + needs: ["set-tags"] + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + ref: ${{ needs.set-tags.outputs.git_ref }} + - name: Setup Rust toolchain + run: rustup show + - name: Clippy + run: SKIP_WASM_BUILD=1 env -u RUSTFLAGS cargo clippy + + build: + runs-on: self-hosted + needs: ["set-tags"] + env: + CARGO_SCCACHE_COMMIT: bed5571c + RUSTFLAGS: "-C opt-level=3 -D warnings" + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + ref: ${{ needs.set-tags.outputs.git_ref }} + - uses: actions/cache@v2 + with: + path: ${{ runner.tool_cache }}/cargo-sccache-${CARGO_SCCACHE_COMMIT} + key: ${{ runner.OS }}-sccache-bin-${{ env.CARGO_SCCACHE_COMMIT }}-v1 + + # With rustup's nice new toml format, we just need to run rustup show to install the toolchain + # https://github.com/actions-rs/toolchain/issues/126#issuecomment-782989659 + - name: Setup Rust toolchain + run: rustup show + - name: SCCache + run: | + # We altered the path to avoid old actions to overwrite it + SCCACHE_PATH=${{ runner.tool_cache }}/cargo-sccache-${CARGO_SCCACHE_COMMIT} + SCCACHE_BIN=${SCCACHE_PATH}/bin/sccache + if [ ! -f $SCCACHE_BIN ]; then + cargo install sccache --git https://github.com/purestake/sccache.git --rev $CARGO_SCCACHE_COMMIT --force --no-default-features --features=dist-client --root $SCCACHE_PATH + fi + ls -la $SCCACHE_BIN + ps aux | grep sccache + if [[ -z `pgrep sccache` ]]; then + chmod +x $SCCACHE_BIN + $SCCACHE_BIN --start-server + fi + $SCCACHE_BIN -s + echo "RUSTC_WRAPPER=$SCCACHE_BIN" >> $GITHUB_ENV + - name: Build Node + run: | + env + cargo build --release --all + - name: Unit tests + run: | + cargo install cargo-expand + cargo test --release --all + + + - name: Cargo check + run: cargo check --release + - name: Save binary + run: | + mkdir -p build + cp target/release/substrate build/substrate; + - name: Upload binary + uses: actions/upload-artifact@v2 + with: + name: substrate + path: build + - name: Save runtime wasm + run: | + mkdir -p runtimes + cp target/release/wbuild/*/*.compact.compressed.wasm runtimes/; + - name: Upload runtimes + uses: actions/upload-artifact@v2 + with: + name: runtimes + path: runtimes + + diff --git a/.github/workflows/md-link-check.yml b/.github/workflows/md-link-check.yml deleted file mode 100644 index 868569911d..0000000000 --- a/.github/workflows/md-link-check.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Check Links - -on: - pull_request: - branches: - - master - push: - branches: - - master - -jobs: - markdown-link-check: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: gaurav-nelson/github-action-markdown-link-check@7481451f70251762f149d69596e3e276ebf2b236 - with: - use-quiet-mode: 'yes' - config-file: '.github/workflows/mlc_config.json' diff --git a/.github/workflows/mlc_config.json b/.github/workflows/mlc_config.json deleted file mode 100644 index e7e620b39e..0000000000 --- a/.github/workflows/mlc_config.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "ignorePatterns": [ - { - "pattern": "^https://crates.io", - } - ] -} diff --git a/.github/workflows/polkadot-companion-labels.yml b/.github/workflows/polkadot-companion-labels.yml deleted file mode 100644 index 0a5af09358..0000000000 --- a/.github/workflows/polkadot-companion-labels.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Check Polkadot Companion and Label - -on: - pull_request: - types: [opened, synchronize] - -jobs: - check_status: - runs-on: ubuntu-latest - steps: - - name: Monitor the status of the gitlab-check-companion-build job - uses: s3krit/await-status-action@v1.0.1 - id: 'check-companion-status' - with: - authToken: ${{ secrets.GITHUB_TOKEN }} - ref: ${{ github.event.pull_request.head.sha }} - contexts: 'continuous-integration/gitlab-check-dependent-polkadot' - timeout: 1800 - notPresentTimeout: 3600 # It can take quite a while before the job starts on Gitlab when the CI queue is large - failureStates: failure - interruptedStates: error # Error = job was probably cancelled. We don't want to label the PR in that case - pollInterval: 30 - - name: Label success - uses: andymckay/labeler@master - if: steps.check-companion-status.outputs.result == 'success' - with: - remove-labels: 'A7-needspolkadotpr' - - name: Label failure - uses: andymckay/labeler@master - if: steps.check-companion-status.outputs.result == 'failure' - with: - add-labels: 'A7-needspolkadotpr' diff --git a/.github/workflows/release-bot.yml b/.github/workflows/release-bot.yml deleted file mode 100644 index ed0a8e5435..0000000000 --- a/.github/workflows/release-bot.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Pushes release updates to a pre-defined Matrix room -on: - release: - types: - - edited - - prereleased - - published -jobs: - ping_matrix: - runs-on: ubuntu-latest - steps: - - name: send message - uses: s3krit/matrix-message-action@v0.0.3 - with: - room_id: ${{ secrets.MATRIX_ROOM_ID }} - access_token: ${{ secrets.MATRIX_ACCESS_TOKEN }} - message: "**${{github.event.repository.full_name}}:** A release has been ${{github.event.action}}
Release version [${{github.event.release.tag_name}}](${{github.event.release.html_url}})

***Description:***
${{github.event.release.body}}
" - server: "matrix.parity.io" diff --git a/.github/workflows/trigger-review-pipeline.yml b/.github/workflows/trigger-review-pipeline.yml deleted file mode 100644 index af54ec4358..0000000000 --- a/.github/workflows/trigger-review-pipeline.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Trigger pipeline for review - -on: - pull_request: - types: [ready_for_review] - -jobs: - trigger: - runs-on: ubuntu-latest - - steps: - - name: Trigger pipeline - run: | - curl -X POST \ - -F token="$TOKEN" \ - -F ref="$REF" \ - https://gitlab.parity.io/api/v4/projects/145/trigger/pipeline - env: - REF: ${{ github.event.number }} - TOKEN: ${{ secrets.GITLAB_TRIGGER_TOKEN }}