-
Notifications
You must be signed in to change notification settings - Fork 0
Actions 設定 #17
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
Merged
Merged
Actions 設定 #17
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b72a177
フォーマット
TwoSquirrels 00e0798
Actions 設定
TwoSquirrels 3777a00
fix: normalize expected paths in search directory tests
TwoSquirrels d63c3fc
fix: update CI workflow for macOS and Windows compatibility; correct …
TwoSquirrels a970b08
fix: enhance CI workflow by adding test job after validation
TwoSquirrels b869e1d
ci: speed up audit job with prebuilt cargo-audit
TwoSquirrels File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| version: 2 | ||
| updates: | ||
| - package-ecosystem: cargo | ||
| directory: / | ||
| schedule: | ||
| interval: weekly | ||
| groups: | ||
| cargo-minor: | ||
| update-types: [minor, patch] | ||
|
|
||
| - package-ecosystem: github-actions | ||
| directory: / | ||
| schedule: | ||
| interval: weekly | ||
| groups: | ||
| github-actions: | ||
| patterns: ['*'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
|
|
||
| concurrency: | ||
| group: ci-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| env: | ||
| CARGO_TERM_COLOR: always | ||
|
|
||
| jobs: | ||
| fmt: | ||
| name: rustfmt | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | ||
| with: | ||
| persist-credentials: false | ||
| - run: cargo fmt --all --check | ||
|
|
||
| clippy: | ||
| name: clippy | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | ||
| with: | ||
| persist-credentials: false | ||
| - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 | ||
| - run: cargo clippy --locked --all-targets --all-features -- -D warnings | ||
|
|
||
| # macOS/Windows はユニットテストとビルド健全性のみ (--bins)。tests/ 配下の統合・E2E テストは | ||
| # GCC 専用 (<bits/stdc++.h> や実 GCC ライブラリ) で clang/MinGW では動かないため、ここでは走らせない。 | ||
| # それらフルスイートは下の coverage ジョブ (Linux + g++ + submodules) で実行している。 | ||
| test: | ||
| name: test (${{ matrix.os }}) | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| os: [macos-latest, macos-26-intel, windows-latest] | ||
| steps: | ||
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | ||
| with: | ||
| persist-credentials: false | ||
| - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 | ||
| - run: cargo test --locked --all-features --bins | ||
|
|
||
| # Linux のフルスイート (ユニット + tests/ の統合・E2E) を計測し、Pages へカバレッジを公開する。 | ||
| coverage: | ||
| name: coverage | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | ||
| with: | ||
| submodules: recursive | ||
| persist-credentials: false | ||
| - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 | ||
| - run: rustup component add llvm-tools-preview | ||
| - uses: taiki-e/install-action@0631aa6515c7d545823c67cfae7ef4fc7f490154 # v2.81.8 | ||
| with: | ||
| tool: cargo-llvm-cov | ||
|
|
||
| - name: Collect coverage | ||
| run: cargo llvm-cov --locked --all-features --no-report | ||
|
|
||
| - name: Build report and badge | ||
| run: | | ||
| cargo llvm-cov report --html --output-dir target/llvm-cov | ||
| pct=$(cargo llvm-cov report --json --summary-only \ | ||
| | jq '.data[0].totals.lines.percent') | ||
| rounded=$(awk -v p="$pct" 'BEGIN { printf "%.1f", p }') | ||
| color=$(awk -v p="$pct" 'BEGIN { | ||
| if (p >= 90) print "brightgreen" | ||
| else if (p >= 75) print "green" | ||
| else if (p >= 60) print "yellowgreen" | ||
| else if (p >= 40) print "yellow" | ||
| else if (p >= 20) print "orange" | ||
| else print "red" | ||
| }') | ||
| mkdir -p _site | ||
| cp -r target/llvm-cov/html/. _site/ | ||
| jq -n --arg m "${rounded}%" --arg c "$color" \ | ||
| '{schemaVersion: 1, label: "coverage", message: $m, color: $c}' > _site/badge.json | ||
|
|
||
| - name: Upload Pages artifact | ||
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
| uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0 | ||
| with: | ||
| path: _site | ||
|
|
||
| deploy-pages: | ||
| name: deploy coverage to Pages | ||
| needs: coverage | ||
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| pages: write | ||
| id-token: write | ||
| environment: | ||
| name: github-pages | ||
| url: ${{ steps.deployment.outputs.page_url }} | ||
| concurrency: | ||
| group: pages | ||
| cancel-in-progress: false | ||
| steps: | ||
| - id: deployment | ||
| uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5.0.0 | ||
|
|
||
| package: | ||
| name: package (publish dry-run) | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | ||
| with: | ||
| persist-credentials: false | ||
| - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 | ||
| - run: cargo publish --locked --dry-run | ||
|
|
||
| audit: | ||
| name: cargo audit | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | ||
| with: | ||
| persist-credentials: false | ||
| - uses: taiki-e/install-action@0631aa6515c7d545823c67cfae7ef4fc7f490154 # v2.81.8 | ||
| with: | ||
| tool: cargo-audit | ||
| - run: cargo audit | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| name: Release | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - "v*" | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| env: | ||
| CARGO_TERM_COLOR: always | ||
|
|
||
| jobs: | ||
| validate: | ||
| name: validate tag | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| release: ${{ steps.check.outputs.release }} | ||
| steps: | ||
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Validate SemVer tag and Cargo.toml version | ||
| id: check | ||
| run: | | ||
| semver='^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$' | ||
| if [[ ! "$GITHUB_REF_NAME" =~ $semver ]]; then | ||
| echo "::notice::tag '$GITHUB_REF_NAME' is not a SemVer release tag; skipping release" | ||
| echo "release=false" >> "$GITHUB_OUTPUT" | ||
| exit 0 | ||
| fi | ||
| tag="${GITHUB_REF_NAME#v}" | ||
| crate="$(cargo metadata --no-deps --format-version 1 \ | ||
| | jq -r '.packages[0].version')" | ||
| if [ "$tag" != "$crate" ]; then | ||
| echo "::error::tag v$tag does not match Cargo.toml version $crate" | ||
| exit 1 | ||
| fi | ||
| echo "release=true" >> "$GITHUB_OUTPUT" | ||
|
|
||
| # タグ push は CI (push/PR トリガー) を起動しないため、公開前にここでフルスイートを回して | ||
| # リリースをテストでゲートする。E2E のため submodules + g++ (ubuntu-latest に同梱) を使う。 | ||
| # リリース文脈では cache を使わない (cache-poisoning を避け、素の環境で検証する)。 | ||
| test: | ||
| name: test | ||
| needs: validate | ||
| if: needs.validate.outputs.release == 'true' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | ||
| with: | ||
| submodules: recursive | ||
| persist-credentials: false | ||
| - run: cargo test --locked --all-features | ||
|
|
||
| publish: | ||
| name: publish to crates.io | ||
| needs: [validate, test] | ||
| if: needs.validate.outputs.release == 'true' | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
| steps: | ||
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Authenticate with crates.io | ||
| id: auth | ||
| uses: rust-lang/crates-io-auth-action@bbd81622f20ce9e2dd9622e3218b975523e45bbe # v1.0.4 | ||
|
|
||
| - name: Publish | ||
| env: | ||
| CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} | ||
| run: cargo publish --locked | ||
|
TwoSquirrels marked this conversation as resolved.
|
||
|
|
||
| binaries: | ||
| name: binary (${{ matrix.target }}) | ||
| needs: [validate, publish] | ||
| if: needs.validate.outputs.release == 'true' | ||
| runs-on: ${{ matrix.os }} | ||
| permissions: | ||
| contents: write | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - os: ubuntu-latest | ||
| target: x86_64-unknown-linux-gnu | ||
| - os: macos-26-intel | ||
| target: x86_64-apple-darwin | ||
| - os: macos-latest | ||
| target: aarch64-apple-darwin | ||
| - os: windows-latest | ||
| target: x86_64-pc-windows-msvc | ||
| steps: | ||
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Build | ||
| run: cargo build --locked --release --target ${{ matrix.target }} | ||
|
|
||
| - name: Archive (Unix) | ||
| if: runner.os != 'Windows' | ||
| run: | | ||
| name="risundle-${GITHUB_REF_NAME}-${{ matrix.target }}" | ||
| tar czf "${name}.tar.gz" -C "target/${{ matrix.target }}/release" risundle | ||
| echo "ASSET=${name}.tar.gz" >> "$GITHUB_ENV" | ||
|
|
||
| - name: Archive (Windows) | ||
| if: runner.os == 'Windows' | ||
| shell: pwsh | ||
| run: | | ||
| $name = "risundle-$env:GITHUB_REF_NAME-${{ matrix.target }}" | ||
| Compress-Archive -Path "target/${{ matrix.target }}/release/risundle.exe" -DestinationPath "$name.zip" | ||
| "ASSET=$name.zip" | Out-File -FilePath $env:GITHUB_ENV -Append | ||
|
|
||
| - name: Upload to release | ||
| uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0 | ||
| with: | ||
| files: ${{ env.ASSET }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.