diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9f7167a9f..a0f25ef59 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,62 +6,108 @@ on: pull_request: merge_group: +# Cancel in-progress runs when a new commit is pushed to the same branch +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: - test_all: - name: Test + # Fast checks first - fail fast on simple issues + # Order: fastest to slowest for single-runner efficiency + + conventional_commits: + name: Conventional Commits + runs-on: self-hosted + if: github.event_name == 'pull_request' - runs-on: freenet-default-runner + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Check PR title follows Conventional Commits + uses: amannn/action-semantic-pull-request@v6 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + types: | + feat + fix + docs + style + refactor + perf + test + build + ci + chore + revert + requireScope: false + subjectPattern: ^(?![A-Z]).+$ + subjectPatternError: | + The subject "{subject}" found in the pull request title "{title}" + didn't match the configured pattern. Please ensure that the subject + doesn't start with an uppercase character. + + fmt_check: + name: Fmt + runs-on: self-hosted + needs: conventional_commits + if: always() && (needs.conventional_commits.result == 'success' || needs.conventional_commits.result == 'skipped') + + steps: + - uses: actions/checkout@v6 + + - uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + components: rustfmt + + - name: Check code formatting + run: cargo fmt -- --check + + clippy_check: + name: Clippy + runs-on: self-hosted + needs: fmt_check env: FREENET_LOG: error CARGO_TARGET_DIR: ${{ github.workspace }}/target steps: - - name: Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.12.1 - with: - access_token: ${{ github.token }} - - uses: actions/checkout@v6 - uses: dtolnay/rust-toolchain@stable with: toolchain: stable + components: clippy targets: wasm32-unknown-unknown - uses: Swatinem/rust-cache@v2 - if: success() || steps.test.conclusion == 'failure' with: save-if: ${{ github.ref == 'refs/heads/main' }} - name: Build run: | - cargo build --locked - export PATH="$PWD/target/debug:$PATH" - make -C apps/freenet-ping -f run-ping.mk build - - - name: Test - run: cargo test --workspace --no-default-features --features trace,websocket,redb + cargo build --locked --bin fdev --manifest-path ../../crates/fdev/Cargo.toml + export PATH="$PWD/../../target/debug:$PATH" + make -f run-ping.mk build + working-directory: apps/freenet-ping - ubertest: - name: Ubertest - needs: test_all - # TODO: Re-enable when ubertest is stable - currently failing - if: false + - name: clippy + run: cargo clippy -- -D warnings - runs-on: freenet-default-runner + test_all: + name: Test + runs-on: self-hosted + needs: clippy_check env: FREENET_LOG: error CARGO_TARGET_DIR: ${{ github.workspace }}/target - UBERTEST_PEER_COUNT: 6 # Fewer peers for faster CI steps: - - name: Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.12.1 - with: - access_token: ${{ github.token }} - - uses: actions/checkout@v6 - uses: dtolnay/rust-toolchain@stable @@ -72,33 +118,33 @@ jobs: - uses: Swatinem/rust-cache@v2 if: success() || steps.test.conclusion == 'failure' with: - save-if: false - - - name: Install riverctl - run: cargo install riverctl + save-if: ${{ github.ref == 'refs/heads/main' }} - name: Build - run: cargo build --locked + run: | + cargo build --locked + export PATH="$PWD/target/debug:$PATH" + make -C apps/freenet-ping -f run-ping.mk build - - name: Run Ubertest - run: cargo test --test ubertest --no-default-features --features trace,websocket,redb - working-directory: crates/core + - name: Clean test directories + run: | + # Remove freenet test directories from /tmp to avoid permission issues + # when tests create directories with different user ownership + rm -rf /tmp/freenet /tmp/freenet-* 2>/dev/null || true + + - name: Test + run: cargo test --workspace --no-default-features --features trace,websocket,redb six_peer_regression: name: six-peer-regression needs: test_all - runs-on: freenet-default-runner - timeout-minutes: 120 + runs-on: self-hosted + timeout-minutes: 30 env: FREENET_LOG: error steps: - - name: Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.12.1 - with: - access_token: ${{ github.token }} - - uses: actions/checkout@v6 with: fetch-depth: 0 @@ -133,18 +179,13 @@ jobs: six_peer_connection_cap: name: six-peer-connection-cap needs: test_all - runs-on: freenet-default-runner + runs-on: self-hosted env: FREENET_LOG: error CARGO_TARGET_DIR: ${{ github.workspace }}/target steps: - - name: Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.12.1 - with: - access_token: ${{ github.token }} - - uses: actions/checkout@v6 - uses: dtolnay/rust-toolchain@stable @@ -163,98 +204,44 @@ jobs: --features trace,websocket,redb,test-network -- connection_cap_respected --nocapture - clippy_check: - name: Clippy - - runs-on: freenet-default-runner + ubertest: + name: Ubertest + needs: test_all + # TODO: Re-enable when ubertest is stable - currently failing + if: false + runs-on: self-hosted env: FREENET_LOG: error CARGO_TARGET_DIR: ${{ github.workspace }}/target + UBERTEST_PEER_COUNT: 6 # Fewer peers for faster CI steps: - - name: Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.12.1 - with: - access_token: ${{ github.token }} - - uses: actions/checkout@v6 - uses: dtolnay/rust-toolchain@stable with: toolchain: stable - components: clippy targets: wasm32-unknown-unknown - uses: Swatinem/rust-cache@v2 + if: success() || steps.test.conclusion == 'failure' with: - save-if: ${{ github.ref == 'refs/heads/main' }} - - - name: Build - run: | - cargo build --locked --bin fdev --manifest-path ../../crates/fdev/Cargo.toml - export PATH="$PWD/../../target/debug:$PATH" - make -f run-ping.mk build - working-directory: apps/freenet-ping - - - name: clippy - run: cargo clippy -- -D warnings - - fmt_check: - name: Fmt - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v6 - - - uses: dtolnay/rust-toolchain@stable - with: - toolchain: stable - components: rustfmt - - - name: Check code formatting - run: cargo fmt -- --check - - conventional_commits: - name: Conventional Commits + save-if: false - runs-on: ubuntu-latest - if: github.event_name == 'pull_request' + - name: Install riverctl + run: cargo install riverctl - steps: - - uses: actions/checkout@v6 - with: - fetch-depth: 0 + - name: Build + run: cargo build --locked - - name: Check PR title follows Conventional Commits - uses: amannn/action-semantic-pull-request@v6 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - types: | - feat - fix - docs - style - refactor - perf - test - build - ci - chore - revert - requireScope: false - subjectPattern: ^(?![A-Z]).+$ - subjectPatternError: | - The subject "{subject}" found in the pull request title "{title}" - didn't match the configured pattern. Please ensure that the subject - doesn't start with an uppercase character. + - name: Run Ubertest + run: cargo test --test ubertest --no-default-features --features trace,websocket,redb + working-directory: crates/core claude-ci-analysis: name: Claude CI Analysis - - runs-on: ubuntu-latest + runs-on: self-hosted needs: [test_all, clippy_check, fmt_check] if: failure() && contains(github.event.pull_request.labels.*.name, 'claude-debug') diff --git a/.github/workflows/cross-compile.yml b/.github/workflows/cross-compile.yml index 86296e090..77584a738 100644 --- a/.github/workflows/cross-compile.yml +++ b/.github/workflows/cross-compile.yml @@ -2,8 +2,7 @@ name: Build and Cross-Compile on: workflow_dispatch: - pull_request: - merge_group: + # Skip PRs - only build on main and releases to reduce CI costs push: branches: [main] tags: ['v*']