From a3da878618ba63f49dcb39791dc847550284699d Mon Sep 17 00:00:00 2001 From: macpie Date: Tue, 14 May 2024 10:04:51 -0700 Subject: [PATCH] Revert "Revert "Attempt to make CI faster" (#809)" This reverts commit a6d1430067f27ff239ddb54130cc44d688fe21b3. --- .github/workflows/CI.yml | 55 +++++++++++++ .github/workflows/Tests.yml | 157 ++++++++++++++++++++++++++++++++++++ .github/workflows/rust.yml | 71 ---------------- 3 files changed, 212 insertions(+), 71 deletions(-) create mode 100644 .github/workflows/CI.yml create mode 100644 .github/workflows/Tests.yml delete mode 100644 .github/workflows/rust.yml diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 000000000..4064d2f0e --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,55 @@ +name: CI + +on: + workflow_run: + workflows: [Tests] + types: [completed] + +env: + CARGO_INCREMENTAL: 0 # this setting is automatically applied by rust-cache but documented here for explicitness + CARGO_NET_RETRY: 10 + RUST_BACKTRACE: short + RUSTFLAGS: "-D warnings" + RUSTUP_MAX_RETRIES: 10 + +jobs: + on-failure: + runs-on: oracles-20.04 + if: ${{ github.event.workflow_run.conclusion == 'failure' }} + steps: + - run: echo 'The triggering workflow failed' + on-success: + runs-on: oracles-20.04 + concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-build-release + cancel-in-progress: true + if: ${{ github.event.workflow_run.conclusion == 'success' }} && contains(github.ref, 'refs/tags/') + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable + with: + components: clippy, rustfmt + + - name: Install protoc + run: sudo apt-get install -y protobuf-compiler + + - name: Cache + uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + - name: Build Release + run: cargo build --all --release + + - name: Debian packaging + env: + PACKAGECLOUD_API_KEY: ${{ secrets.PACKAGECLOUD_API_KEY }} + run: | + chmod +x ./.github/scripts/make_debian.sh + ./.github/scripts/make_debian.sh diff --git a/.github/workflows/Tests.yml b/.github/workflows/Tests.yml new file mode 100644 index 000000000..53fb79e4f --- /dev/null +++ b/.github/workflows/Tests.yml @@ -0,0 +1,157 @@ +name: Tests + +on: + pull_request: + branches: [main] + push: + branches: ["main"] + tags: ["*"] + +env: + CARGO_INCREMENTAL: 0 # this setting is automatically applied by rust-cache but documented here for explicitness + CARGO_NET_RETRY: 10 + RUST_BACKTRACE: short + RUSTFLAGS: "-D warnings" + RUSTUP_MAX_RETRIES: 10 + +jobs: + + build: + runs-on: oracles-20.04 + concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-build + cancel-in-progress: true + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Rust install + uses: dtolnay/rust-toolchain@stable + + - name: Install protoc + run: sudo apt-get install -y protobuf-compiler + + - name: Cache + uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + - name: Build + run: cargo build --all --tests + + fmt: + needs: build + runs-on: oracles-20.04 + concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-fmt + cancel-in-progress: true + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Rust install + uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt + + - name: Install protoc + run: sudo apt-get install -y protobuf-compiler + + - name: Cache + uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + - name: Check formatting + run: cargo fmt -- --check + clippy: + needs: build + runs-on: oracles-20.04 + concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-clippy + cancel-in-progress: true + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Rust install + uses: dtolnay/rust-toolchain@stable + with: + components: clippy + + - name: Install protoc + run: sudo apt-get install -y protobuf-compiler + + - name: Cache + uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + - name: Clippy + run: cargo clippy --all-targets -- -Dclippy::all -D warnings + + tests: + needs: build + runs-on: oracles-20.04 + strategy: + fail-fast: false + matrix: + package: [boost-manager,file-store,ingest,iot-config,iot-packet-verifier,iot-verifier,mobile-config,mobile-packet-verifier,mobile-verifier,reward-scheduler,task-manager] + concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-tests-${{ matrix.package }} + cancel-in-progress: true + services: + postgres: + image: postgres + env: + POSTGRES_PASSWORD: postgres + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Rust install + uses: dtolnay/rust-toolchain@stable + + - name: Install protoc + run: sudo apt-get install -y protobuf-compiler + + - name: Cache + uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + - name: Run unit and integration tests + env: + DATABASE_URL: "postgres://postgres:postgres@localhost:5432/postgres" + run: cargo test -p ${{ matrix.package }} -- --include-ignored \ No newline at end of file diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml deleted file mode 100644 index c141ecc9e..000000000 --- a/.github/workflows/rust.yml +++ /dev/null @@ -1,71 +0,0 @@ -name: CI - -on: - pull_request: - branches: [main] - push: - branches: [main] - tags: ["*"] - -env: - CARGO_INCREMENTAL: 0 # this setting is automatically applied by rust-cache but documented here for explicitness - CARGO_NET_RETRY: 10 - RUST_BACKTRACE: short - RUSTFLAGS: "-D warnings" - RUSTUP_MAX_RETRIES: 10 - -jobs: - build: - runs-on: oracles-20.04 - - services: - postgres: - image: postgres - env: - POSTGRES_PASSWORD: postgres - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - - 5432:5432 - - steps: - - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable - with: - components: clippy, rustfmt - - - name: Install protoc - run: sudo apt-get install -y protobuf-compiler - - - name: Setup cache - uses: Swatinem/rust-cache@v2 - - - name: Cancel previous runs - uses: styfle/cancel-workflow-action@0.11.0 - with: - access_token: ${{ github.token }} - - - name: Build - run: cargo build --all --release - - - name: Check formatting - run: cargo fmt -- --check - - - name: Clippy - run: cargo clippy --all-targets -- -Dclippy::all -D warnings - - - name: Run unit and integration tests - env: - DATABASE_URL: "postgres://postgres:postgres@localhost:5432/postgres" - run: cargo test -r -- --include-ignored - - - name: Debian packaging - if: contains(github.ref, 'refs/tags/') - env: - PACKAGECLOUD_API_KEY: ${{ secrets.PACKAGECLOUD_API_KEY }} - run: | - chmod +x ./.github/scripts/make_debian.sh - ./.github/scripts/make_debian.sh