Skip to content

Commit dd9642c

Browse files
committed
Revert "Remove Cargo workspace CI checks and dummy crate"
This reverts commit 5091a4c.
1 parent 5091a4c commit dd9642c

File tree

6 files changed

+201
-0
lines changed

6 files changed

+201
-0
lines changed

.github/workflows/checks.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Checks
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- '.snippets/code/**'
9+
- '.github/workflows/**'
10+
pull_request:
11+
types: [opened, synchronize, reopened, ready_for_review]
12+
paths:
13+
- '.snippets/code/**'
14+
- '.github/workflows/**'
15+
merge_group:
16+
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
preflight:
23+
uses: ./.github/workflows/reusable-preflight.yml
24+
25+
fmt:
26+
runs-on: ubuntu-latest
27+
timeout-minutes: 20
28+
needs: [preflight]
29+
container:
30+
image: ${{ needs.preflight.outputs.IMAGE }}
31+
steps:
32+
- uses: actions/checkout@v4
33+
- name: Cargo fmt
34+
working-directory: .snippets/code
35+
run: cargo +nightly fmt --all -- --check
36+
37+
clippy:
38+
runs-on: ubuntu-latest
39+
timeout-minutes: 20
40+
needs: [preflight]
41+
container:
42+
image: ${{ needs.preflight.outputs.IMAGE }}
43+
steps:
44+
- uses: actions/checkout@v4
45+
- name: Clippy check
46+
working-directory: .snippets/code
47+
run: |
48+
cargo clippy --all-targets --locked --workspace --quiet
49+
50+
test:
51+
runs-on: ubuntu-latest
52+
timeout-minutes: 20
53+
needs: [preflight]
54+
container:
55+
image: ${{ needs.preflight.outputs.IMAGE }}
56+
steps:
57+
- uses: actions/checkout@v4
58+
- name: Run tests
59+
working-directory: .snippets/code
60+
run: cargo test
61+
62+
check-fail-ci:
63+
runs-on: ubuntu-latest
64+
container:
65+
image: "paritytech/tools:latest"
66+
options: --user root
67+
steps:
68+
- uses: actions/checkout@v4
69+
- name: Check
70+
working-directory: .snippets/code
71+
run: |
72+
set +e
73+
rg --line-number --hidden --type rust --glob '!{.git,target}' "$ASSERT_REGEX" .; exit_status=$?
74+
if [ $exit_status -eq 0 ]; then
75+
echo "$ASSERT_REGEX was found, exiting with 1";
76+
exit 1;
77+
else
78+
echo "No $ASSERT_REGEX was found, exiting with 0";
79+
exit 0;
80+
fi
81+
env:
82+
ASSERT_REGEX: "FAIL-CI"
83+
GIT_DEPTH: 1
84+
85+
confirm-checks:
86+
runs-on: ubuntu-latest
87+
name: All checks passed
88+
needs:
89+
- fmt
90+
- clippy
91+
- test
92+
- check-fail-ci
93+
if: always() && !cancelled()
94+
steps:
95+
- run: |
96+
tee resultfile <<< '${{ toJSON(needs) }}'
97+
FAILURES=$(cat resultfile | grep '"result": "failure"' | wc -l)
98+
if [ $FAILURES -gt 0 ]; then
99+
echo "### At least one required job failed ❌" >> $GITHUB_STEP_SUMMARY
100+
exit 1
101+
else
102+
echo '### Good job! All the required jobs passed 🚀' >> $GITHUB_STEP_SUMMARY
103+
fi
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Preflight
2+
3+
on:
4+
workflow_call:
5+
outputs:
6+
changes_rust:
7+
value: ${{ jobs.preflight.outputs.changes_rust }}
8+
changes_currentWorkflow:
9+
value: ${{ jobs.preflight.outputs.changes_currentWorkflow }}
10+
IMAGE:
11+
value: ${{ jobs.preflight.outputs.IMAGE }}
12+
description: "CI image"
13+
14+
jobs:
15+
preflight:
16+
runs-on: ubuntu-latest
17+
outputs:
18+
changes_rust: ${{ steps.set_changes.outputs.rust_any_changed || steps.set_changes.outputs.currentWorkflow_any_changed }}
19+
changes_currentWorkflow: ${{ steps.set_changes.outputs.currentWorkflow_any_changed }}
20+
IMAGE: ${{ steps.set_image.outputs.IMAGE }}
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: Current file
26+
id: current_file
27+
shell: bash
28+
run: |
29+
echo "currentWorkflowFile=$(echo ${{ github.workflow_ref }} | sed -nE "s/.*(\.github\/workflows\/[a-zA-Z0-9_-]*\.y[a]?ml)@refs.*/\1/p")" >> $GITHUB_OUTPUT
30+
echo "currentActionDir=$(echo ${{ github.action_path }} | sed -nE "s/.*(\.github\/actions\/[a-zA-Z0-9_-]*)/\1/p")" >> $GITHUB_OUTPUT
31+
32+
- name: Set changes
33+
id: set_changes
34+
uses: tj-actions/changed-files@v45
35+
with:
36+
files_yaml: |
37+
rust:
38+
- '.snippets/code/**/*'
39+
- '!.github/**/*'
40+
- '!docs/**/*'
41+
currentWorkflow:
42+
- '${{ steps.current_file.outputs.currentWorkflowFile }}'
43+
- '.github/workflows/reusable-preflight.yml'
44+
45+
- name: Set image
46+
id: set_image
47+
shell: bash
48+
run: cat .github/env >> $GITHUB_OUTPUT

.snippets/code/Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.snippets/code/Cargo.toml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
[workspace.package]
2+
license = "MIT-0"
3+
authors = [
4+
"Parity Technologies <[email protected]>",
5+
"Web3 Foundation",
6+
"PaperMoon.io",
7+
]
8+
homepage = "docs.polkadot.com"
9+
repository = "https://github.com/paritytech/polkadot-sdk-parachain-template.git"
10+
edition = "2021"
11+
12+
[workspace]
13+
members = ["dummy"]
14+
resolver = "2"
15+
16+
[workspace.dependencies]
17+
clap = { version = "4.5.13" }
18+
color-print = { version = "0.3.4" }
19+
docify = { version = "0.2.9" }
20+
futures = { version = "0.3.31" }
21+
jsonrpsee = { version = "0.24.3" }
22+
log = { version = "0.4.22", default-features = false }
23+
polkadot-sdk = { version = "2503.0.1", default-features = false }
24+
prometheus-endpoint = { version = "0.17.2", default-features = false, package = "substrate-prometheus-endpoint" }
25+
serde = { version = "1.0.214", default-features = false }
26+
codec = { version = "3.7.4", default-features = false, package = "parity-scale-codec" }
27+
cumulus-pallet-parachain-system = { version = "0.20.0", default-features = false }
28+
hex-literal = { version = "0.4.1", default-features = false }
29+
scale-info = { version = "2.11.6", default-features = false }
30+
serde_json = { version = "1.0.132", default-features = false }
31+
smallvec = { version = "1.11.0", default-features = false }
32+
substrate-wasm-builder = { version = "26.0.1", default-features = false }
33+
frame = { version = "0.9.1", default-features = false, package = "polkadot-sdk-frame" }

.snippets/code/dummy/Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[package]
2+
name = "dummy"
3+
version = "0.1.0"
4+
edition = "2021"
5+
publish = false
6+
7+
# This is a placeholder crate to satisfy the Cargo workspace requirements.
8+
# The actual code snippets in this repository are standalone files used for documentation.

.snippets/code/dummy/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Placeholder crate for CI workspace requirements.
2+
// See .snippets/code/Cargo.toml for details.

0 commit comments

Comments
 (0)