Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Use shared cache between tests, lints and e2e, better lints #1743

Merged
merged 16 commits into from
Aug 4, 2023
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ jobs:
uses: Swatinem/rust-cache@v2
with:
cache-directories: ~/.cache/sccache
shared-key: nox
# github allows only 10GB of cache
# so save cache only on merge to master
# to use less space and speed up CI
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ jobs:
run_number=${{ github.run_number }}
run_attempt=${{ github.run_attempt }}
cache-from: type=gha
cache-to: type=gha,mode=max
# github allows only 10GB of cache
# so save cache only on merge to master
# to use less space and speed up CI
cache-to: ${{ github.event == 'push' && 'type=gha,mode=max' || '' }}

- name: Print results to check summary
if: always()
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/lint-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: lint PR

on:
pull_request:
types:
- opened
- edited
- synchronize

concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true

jobs:
title:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26 changes: 14 additions & 12 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,15 @@ name: lint

on:
pull_request:
types:
- opened
- edited
- synchronize
paths:
- ".github/workflows/**"
- ".github/renovate.json"

concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true

jobs:
pr:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

reviewdog:
runs-on: ubuntu-latest
steps:
Expand All @@ -33,3 +24,14 @@ jobs:
with:
reporter: github-pr-check
fail_on_error: true

renovate:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Renovate Config Validator
uses: tj-actions/renovate-config-validator@v2
with:
config_file: .github/renovate.json
59 changes: 5 additions & 54 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,65 +21,16 @@ on:
required: true

jobs:
nox:
name: "Build nox (${{ matrix.arch }})"
runs-on: builder
timeout-minutes: 60

permissions:
contents: write
id-token: write

strategy:
fail-fast: false
matrix:
include:
- arch: x86_64
env:
RUSTFLAGS: "-D warnings --cfg tokio_unstable"
- arch: aarch64
env:
RUSTFLAGS: "-D warnings --cfg tokio_unstable"
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
CC_aarch64_unknown_linux_gnu: aarch64-linux-gnu-gcc
CXX_aarch64_unknown_linux_gnu: aarch64-linux-gnu-g++

env: ${{ matrix.env }}

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Rust toolchain
uses: dsherret/rust-toolchain-file@v1

- name: Import secrets
uses: hashicorp/vault-action@v2.7.3
with:
url: https://vault.fluence.dev
path: jwt/github
role: ci
method: jwt
jwtGithubAudience: "https://github.com/fluencelabs"
jwtTtl: 300
exportToken: false
secrets: |
kv/crates.io/fluencebot token | CARGO_REGISTRY_TOKEN

- name: Run cargo build
run: cargo build --release -p nox --target ${{ matrix.arch }}-unknown-linux-gnu

- name: Upload nox binary
uses: actions/upload-artifact@v3
with:
name: nox-${{ matrix.arch }}
path: target/${{ matrix.arch }}-unknown-linux-gnu/release/nox
build:
uses: ./.github/workflows/build.yml
with:
ref: ${{ github.ref }}

upload:
runs-on: ubuntu-latest
timeout-minutes: 60

needs: nox
needs: build

permissions:
contents: write
Expand Down
50 changes: 46 additions & 4 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: "test"
on:
pull_request:
paths-ignore:
- "!**.md"
push:
branches:
- "master"
- "**.md"
- ".github/**"
- "!.github/workflows/run-tests.yml"
- "!.github/workflows/tests.yml"

concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
Expand All @@ -17,3 +17,45 @@ jobs:
uses: ./.github/workflows/tests.yml
with:
ref: ${{ github.ref }}

lints:
runs-on: builder

env:
RUSTFLAGS: "-D warnings --cfg tokio_unstable -C link-arg=-B/usr/local/bin/mold"
RUSTC_WRAPPER: "sccache"

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Rust toolchain
uses: dsherret/rust-toolchain-file@v1

- name: Setup cache
uses: Swatinem/rust-cache@v2
with:
cache-directories: ~/.cache/sccache
shared-key: nox
save-if: false

- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.3

- name: Setup mold linker
uses: rui314/setup-mold@v1
with:
make-default: false

- name: Run cargo check
run: cargo check

- name: Run cargo clippy
uses: giraffate/clippy-action@v1
with:
reporter: github-pr-review
clippy_flags: -Z unstable-options --all
fail_on_error: true

- name: Run cargo fmt
uses: actions-rust-lang/rustfmt@v1
28 changes: 17 additions & 11 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ on:
default: "null"

env:
RUSTFLAGS: "-D warnings --cfg tokio_unstable"
RUSTFLAGS: "-D warnings --cfg tokio_unstable -C link-arg=-B/usr/local/bin/mold"
RUSTC_WRAPPER: "sccache"

jobs:
tests:
Expand All @@ -31,6 +32,21 @@ jobs:
- name: Setup Rust toolchain
uses: dsherret/rust-toolchain-file@v1

- name: Setup cache
uses: Swatinem/rust-cache@v2
with:
cache-directories: ~/.cache/sccache
shared-key: nox
save-if: false

- name: Setup sccache
uses: mozilla-actions/sccache-action@v0.0.3

- name: Setup mold linker
uses: rui314/setup-mold@v1
with:
make-default: false

- name: Setup nextest
uses: taiki-e/install-action@nextest

Expand All @@ -50,13 +66,3 @@ jobs:
name: nox report
path: target/nextest/ci/junit.xml
reporter: java-junit

- name: Run cargo fmt
run: cargo fmt --all -- --check

- name: Run cargo clippy
uses: giraffate/clippy-action@v1
with:
reporter: github-pr-review
clippy_flags: -Z unstable-options --all
fail_on_error: true
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ members = [
"script-storage",
"spell-storage",
"particle-execution",
"crates/system-services"
"crates/system-services",
]
exclude = [
"nox/tests/tetraplets",
Expand Down
Loading