Skip to content

Commit fbcbc19

Browse files
committed
gha workflows [skip ci]
1 parent 8b19919 commit fbcbc19

File tree

9 files changed

+745
-186
lines changed

9 files changed

+745
-186
lines changed

.circleci/config.yml

Lines changed: 0 additions & 186 deletions
This file was deleted.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: 'Get Version Info'
2+
description: 'Extracts version information from Cargo.toml and compares with previous commit'
3+
4+
inputs:
5+
cargo_toml_path:
6+
description: 'Path to the Cargo.toml file to extract version from'
7+
required: false
8+
default: 'crates/starknet-devnet/Cargo.toml'
9+
force_version_tags:
10+
description: 'Force version tags regardless of version change'
11+
required: false
12+
default: 'false'
13+
14+
outputs:
15+
version:
16+
description: 'The current version from Cargo.toml'
17+
value: ${{ steps.get_version.outputs.version }}
18+
is_rc:
19+
description: 'Whether the version is a release candidate'
20+
value: ${{ steps.check_rc.outputs.is_rc }}
21+
version_changed:
22+
description: 'Whether the version has changed from the previous commit'
23+
value: ${{ steps.compare_versions.outputs.version_changed }}
24+
previous_version:
25+
description: 'The previous version from the last commit (empty if not available)'
26+
value: ${{ steps.get_previous_version.outputs.previous_version }}
27+
28+
runs:
29+
using: 'composite'
30+
steps:
31+
- name: Get current version
32+
id: get_version
33+
shell: bash
34+
run: |
35+
VERSION=$(grep -E '^version = "[0-9]+\.[0-9]+\.[0-9]+"$' ${{ inputs.cargo_toml_path }} | head -n 1 | cut -d'"' -f2)
36+
echo "version=$VERSION" >> $GITHUB_OUTPUT
37+
38+
- name: Check if version is a release candidate
39+
id: check_rc
40+
shell: bash
41+
run: |
42+
VERSION="${{ steps.get_version.outputs.version }}"
43+
if [[ "$VERSION" == *"rc"* ]]; then
44+
echo "is_rc=true" >> $GITHUB_OUTPUT
45+
else
46+
echo "is_rc=false" >> $GITHUB_OUTPUT
47+
fi
48+
49+
- name: Get previous version
50+
id: get_previous_version
51+
shell: bash
52+
run: |
53+
git fetch --depth=2 || true
54+
55+
PREVIOUS_VERSION=""
56+
if git rev-parse HEAD~1 &>/dev/null; then
57+
PREVIOUS_VERSION=$(git show HEAD~1:${{ inputs.cargo_toml_path }} 2>/dev/null | grep "^version" | sed -E 's/.*"(.*)"/\1/' || echo "")
58+
fi
59+
60+
echo "previous_version=$PREVIOUS_VERSION" >> $GITHUB_OUTPUT
61+
62+
- name: Compare versions
63+
id: compare_versions
64+
shell: bash
65+
run: |
66+
CURRENT_VERSION="${{ steps.get_version.outputs.version }}"
67+
PREVIOUS_VERSION="${{ steps.get_previous_version.outputs.previous_version }}"
68+
FORCE_TAGS="${{ inputs.force_version_tags }}"
69+
70+
if [[ -n "$PREVIOUS_VERSION" && "$CURRENT_VERSION" != "$PREVIOUS_VERSION" ]] || [[ "$FORCE_TAGS" == "true" ]]; then
71+
echo "version_changed=true" >> $GITHUB_OUTPUT
72+
else
73+
echo "version_changed=false" >> $GITHUB_OUTPUT
74+
fi
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: 'Load Common Configuration'
2+
description: 'Loads common configuration values and sets them as outputs'
3+
4+
outputs:
5+
rust_stable_version:
6+
description: 'Stable Rust version to use'
7+
value: '1.86.0'
8+
rust_nightly_version:
9+
description: 'Nightly Rust version to use'
10+
value: 'nightly-2025-02-20'
11+
docker_registry:
12+
description: 'Docker registry to use'
13+
value: 'docker.io'
14+
docker_namespace:
15+
description: 'Docker namespace to use'
16+
value: 'shardlabs'
17+
image_name:
18+
description: 'Docker image name to use'
19+
value: 'starknet-devnet-rs'
20+
21+
runs:
22+
using: 'composite'
23+
steps:
24+
- run: echo "Configuration loaded"
25+
shell: bash

.github/workflow-config.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# This file contains reusable configurations for GitHub Actions workflows
2+
# It defines common environments, permissions, concurrency settings, etc.
3+
4+
name: Common Config
5+
6+
# Environment variables used across workflows
7+
env:
8+
RUST_STABLE_VERSION: 1.86.0
9+
RUST_NIGHTLY_VERSION: nightly-2025-02-20
10+
DOCKER_REGISTRY: docker.io
11+
DOCKER_NAMESPACE: 0xspaceshard
12+
IMAGE_NAME: starknet-devnet
13+
14+
# Default permissions required for workflows
15+
permissions:
16+
contents: read
17+
18+
# Define concurrency groups to avoid running redundant workflows
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
21+
cancel-in-progress: true
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Build and Test
2+
3+
on:
4+
push:
5+
pull_request:
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
build-and-test:
17+
name: Build and Test
18+
runs-on: self-hosted
19+
outputs:
20+
version: ${{ steps.get_version.outputs.version }}
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: Load common configuration
26+
id: config
27+
uses: ./.github/actions/load-config
28+
29+
- name: Get version
30+
id: get_version
31+
run: |
32+
VERSION=$(grep -E '^version = "[0-9]+\.[0-9]+\.[0-9]+"$' crates/starknet-devnet/Cargo.toml | head -n 1 | cut -d'"' -f2)
33+
echo "version=$VERSION" >> $GITHUB_OUTPUT
34+
35+
- name: Set up Rust stable
36+
uses: dtolnay/rust-toolchain@master
37+
with:
38+
toolchain: ${{ steps.config.outputs.rust_stable_version }}
39+
components: clippy, rustfmt
40+
41+
- name: Set up Rust nightly
42+
uses: dtolnay/rust-toolchain@master
43+
with:
44+
toolchain: ${{ steps.config.outputs.rust_nightly_version }}
45+
components: rustfmt
46+
47+
- name: Install Foundry
48+
uses: foundry-rs/[email protected]
49+
with:
50+
version: nightly-5b7e4cb3c882b28f3c32ba580de27ce7381f415a
51+
52+
- name: Verify lockfile
53+
run: cargo update -w --locked
54+
55+
- name: Run cargo check
56+
run: cargo check --workspace --all-targets
57+
58+
- name: Run clippy check
59+
run: |
60+
cargo clippy --workspace -- -Dwarnings
61+
cargo clippy --workspace --all-features -- -Dwarnings
62+
cargo clippy --workspace --tests -- -Dwarnings
63+
64+
- name: Check code formatting
65+
run: |
66+
cargo +${{ steps.config.outputs.rust_nightly_version }} fmt --all --check
67+
cd website && npm ci && npm run format-check
68+
69+
- name: Check spelling
70+
run: |
71+
cargo +${{ steps.config.outputs.rust_nightly_version }} install typos-cli --version 1.36.2 --locked
72+
typos && echo "No spelling errors!"
73+
74+
- name: Build in release mode
75+
run: cargo build --release
76+
77+
- name: Run tests
78+
run: RUST_BACKTRACE=full cargo test --no-fail-fast

0 commit comments

Comments
 (0)