Skip to content

Commit 5bc989d

Browse files
authored
fix: update CI PR (#56)
1 parent dfe9078 commit 5bc989d

File tree

7 files changed

+244
-56
lines changed

7 files changed

+244
-56
lines changed
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Prune unnecessary cache
2+
3+
inputs:
4+
key-prefix:
5+
description: The cache key prefix to prune
6+
required: true
7+
github-token:
8+
description: The GH token to use for the API request
9+
required: true
10+
11+
description: Prune unnecessary cache for the provided key
12+
13+
runs:
14+
using: composite
15+
steps:
16+
- name: Obtain cache entry to delete
17+
id: fetch-outdated-cache
18+
shell: bash
19+
run: |
20+
CACHE=$(curl \
21+
-H "Accept: application/vnd.github.v3+json" \
22+
-H "Authorization: token ${{ inputs.github-token }}" \
23+
https://api.github.com/repos/logos-co/nomos-node/actions/caches | jq '.actions_caches[] | select(.key | startswith("${{ inputs.key-prefix }}")) | .id')
24+
echo "cache=$CACHE" >> "$GITHUB_OUTPUT"
25+
continue-on-error: true
26+
- name: Delete cache entry
27+
if: steps.fetch-outdated-cache.outputs.cache != null
28+
shell: bash
29+
run: |
30+
curl -X DELETE \
31+
-H "Accept: application/vnd.github.v3+json" \
32+
-H "Authorization: token ${{ inputs.github-token }}" \
33+
https://api.github.com/repos/logos-co/nomos-node/actions/caches/${{ steps.fetch-outdated-cache.outputs.cache }}
34+
continue-on-error: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Setup Cargo cache
2+
3+
inputs:
4+
key:
5+
description: The key to use for the cache
6+
required: true
7+
github-token:
8+
description: Valid GitHub token to interact with GitHub REST API
9+
required: true
10+
11+
description: Set up cache read operations for Cargo artifacts
12+
13+
runs:
14+
using: composite
15+
steps:
16+
- name: Set up Cargo cache
17+
uses: actions/cache/restore@v4
18+
with:
19+
path: |
20+
~/.cargo/registry/index/
21+
~/.cargo/registry/cache/
22+
~/.cargo/git/db/
23+
target/
24+
# Must be in sync with the key used in the update-cargo-cache action
25+
key: ${{ inputs.key }}->#${{ github.run_id }}
26+
restore-keys: |
27+
${{ inputs.key }}
28+
continue-on-error: true
29+
- name: Delete retrieved cache
30+
uses: ./.github/actions/prune-cache
31+
with:
32+
key-prefix: ${{ inputs.key }}->#
33+
github-token: ${{ inputs.github-token }}
34+
continue-on-error: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Update Cargo cache
2+
3+
inputs:
4+
key:
5+
description: The key to use for the cache
6+
required: true
7+
8+
description: Update the Cargo artifacts cache at the provided key
9+
10+
runs:
11+
using: composite
12+
steps:
13+
- name: Set up Cargo cache
14+
uses: actions/cache/save@v4
15+
with:
16+
path: |
17+
~/.cargo/registry/index/
18+
~/.cargo/registry/cache/
19+
~/.cargo/git/db/
20+
target/
21+
# Must be in sync with the key used in the setup-cargo-cache action
22+
key: ${{ inputs.key }}->#${{ github.run_id }}
23+
continue-on-error: true

.github/workflows/code-check.yml

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
on:
2+
pull_request:
3+
push:
4+
branches: [ master ]
5+
6+
name: Code checks
7+
8+
concurrency:
9+
group: ${{ github.workflow }}@${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
formatting:
14+
name: Check formatting
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
- name: Install nightly toolchain
20+
uses: actions-rs/toolchain@v1
21+
with:
22+
toolchain: nightly-2025-01-03
23+
profile: minimal
24+
components: rustfmt
25+
override: true
26+
- name: Run cargo fmt
27+
uses: actions-rs/cargo@v1
28+
with:
29+
command: fmt
30+
args: --all --check
31+
32+
cargo-deny:
33+
name: Check cargo-deny rules
34+
runs-on: ubuntu-latest
35+
36+
steps:
37+
- name: Checkout repository
38+
uses: actions/checkout@v4
39+
- name: Run `cargo deny`
40+
uses: EmbarkStudios/cargo-deny-action@v2
41+
with:
42+
# All is set in the config file
43+
arguments:
44+
command-arguments: "--hide-inclusion-graph -c .cargo-deny.toml --show-stats -D warnings"
45+
46+
lints:
47+
name: Check Rust lints
48+
runs-on: ubuntu-latest
49+
steps:
50+
- name: Checkout repository
51+
uses: actions/checkout@v4
52+
- name: Set up Cargo cache
53+
uses: ./.github/actions/setup-cargo-cache
54+
with:
55+
key: ${{ github.ref }}->${{ github.workflow }}->${{ github.job }}
56+
github-token: ${{ secrets.GITHUB_TOKEN }}
57+
- name: Run cargo clippy
58+
uses: actions-rs/cargo@v1
59+
with:
60+
command: clippy
61+
args: --all --all-targets --all-features -- -D warnings
62+
- name: Update Cargo cache
63+
if: success() || failure()
64+
uses: ./.github/actions/update-cargo-cache
65+
with:
66+
key: ${{ github.ref }}->${{ github.workflow }}->${{ github.job }}
67+
68+
tests:
69+
name: Run test suite
70+
strategy:
71+
fail-fast: false
72+
matrix:
73+
os: [ubuntu-latest, windows-latest, macos-latest]
74+
runs-on: ${{ matrix.os }}
75+
steps:
76+
- name: Checkout repository
77+
uses: actions/checkout@v4
78+
- name: Set up Cargo cache
79+
uses: ./.github/actions/setup-cargo-cache
80+
with:
81+
key: ${{ github.ref }}->${{ github.workflow }}->${{ github.job }}->${{ matrix.os }}
82+
github-token: ${{ secrets.GITHUB_TOKEN }}
83+
- name: Cargo test
84+
uses: actions-rs/cargo@v1
85+
with:
86+
command: test
87+
args: --all-targets --all-features
88+
- name: Update Cargo cache
89+
if: success() || failure()
90+
uses: ./.github/actions/update-cargo-cache
91+
with:
92+
key: ${{ github.ref }}->${{ github.workflow }}->${{ github.job }}->${{ matrix.os }}

.github/workflows/codecov.yml

+6-5
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ jobs:
1212
RUSTFLAGS: -C instrument-coverage
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/checkout@v4
16-
with:
17-
submodules: true
18-
- run: rustup component add llvm-tools-preview
19-
- run: |
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
- name: Add llvm-tools-preview component
18+
run: rustup component add llvm-tools-preview
19+
- name: Run Grcov
20+
run: |
2021
cargo install grcov;
2122
cargo test --all-features;
2223
mkdir /tmp/cov;

.github/workflows/main.yml

-51
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Check for a new Rust version
2+
3+
on:
4+
schedule:
5+
- cron: "0 3 * * *"
6+
7+
jobs:
8+
check-latest-version:
9+
name: Fetch and compare latest Rust release
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v4
14+
- name: Fetch latest Rust release
15+
id: latest-version
16+
run: |
17+
LATEST=$(curl -s https://api.github.com/repos/rust-lang/rust/releases/latest | jq -r .tag_name)
18+
echo "Latest Rust version: $LATEST"
19+
echo "VERSION=$LATEST" >> $GITHUB_OUTPUT
20+
- name: Retrieve local Rust version
21+
id: installed-version
22+
run: |
23+
INSTALLED=$(cargo --version | awk '{print $2}')
24+
echo "Installed Rust version: $INSTALLED"
25+
echo "VERSION=$INSTALLED" >> $GITHUB_OUTPUT
26+
- name: Compare latest and local Rust versions
27+
id: compare-versions
28+
run: |
29+
if [ "${{ steps.latest-version.outputs.VERSION }}" != "${{ steps.installed-version.outputs.VERSION }}" ]; then
30+
NEW_VERSION_AVAILABLE=true
31+
else
32+
NEW_VERSION_AVAILABLE=false
33+
fi
34+
echo "NEW_VERSION_AVAILABLE=$NEW_VERSION_AVAILABLE" >> $GITHUB_OUTPUT
35+
outputs:
36+
new-version-available: ${{ steps.compare-versions.outputs.NEW_VERSION_AVAILABLE }}
37+
new-version: ${{ steps.latest-version.outputs.VERSION }}
38+
notify-new-version:
39+
name: Notify of new Rust version
40+
runs-on: ubuntu-latest
41+
needs: check-latest-version
42+
if: ${{ needs.check-latest-version.outputs.new-version-available == 'true' }}
43+
steps:
44+
- name: Checkout repository
45+
uses: actions/checkout@v4
46+
- name: Create a GH issue (if it does not exist)
47+
uses: JasonEtco/create-an-issue@v2
48+
env:
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
RUST_VERSION: ${{ needs.check-latest-version.outputs.new-version }}
51+
with:
52+
assignees: danielSanchezQ, ntn-x2
53+
filename: ./.github/rust_update_issue_template.md
54+
update_existing: false
55+
search_existing: all

0 commit comments

Comments
 (0)