Skip to content

Commit

Permalink
Merge pull request #225 from H1rono/ci
Browse files Browse the repository at this point in the history
🔧 CI周り更新
  • Loading branch information
H1rono authored Oct 13, 2024
2 parents 8c77cf6 + 5c99a03 commit 09c29ca
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 52 deletions.
18 changes: 0 additions & 18 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,6 @@

version: 2
updates:
- package-ecosystem: "cargo" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
reviewers:
- "H1rono"
- package-ecosystem: "cargo"
directory: "/examples/basic-with-axum"
schedule:
interval: "weekly"
reviewers:
- "H1rono"
- package-ecosystem: "cargo"
directory: "/examples/basic-with-rocket"
schedule:
interval: "weekly"
reviewers:
- "H1rono"
- package-ecosystem: "github-actions" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ permissions:
on:
schedule:
- cron: '0 0 1 * *'
workflow_dispatch:

jobs:
audit:
Expand Down
31 changes: 21 additions & 10 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,31 @@ env:
GRCOV_VERSION: "0.8.19"

jobs:
nix-build:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install nix
uses: cachix/install-nix-action@v29
with:
nix_path: "nixpkgs=channel:release-23.05"
- name: Nix cache
uses: DeterminateSystems/magic-nix-cache-action@v8
- name: Checks
run: nix flake check
- name: Rust cache
uses: Swatinem/rust-cache@v2
- name: Build
run: nix build
run: |
cargo build --workspace
cargo build --package traq-bot-http --no-default-features
cargo build --package traq-bot-http --features time
cargo build --package traq-bot-http --features 'uuid chrono'
cargo build --package traq-bot-http --features http
cargo build --package traq-bot-http --all-features
- name: Lint
run: |
cargo clippy --workspace -- -D warnings
cargo clippy --package traq-bot-http --no-default-features -- -D warnings
cargo clippy --package traq-bot-http --features 'uuid time' -- -D warnings
cargo clippy --package traq-bot-http --features 'chrono http' -- -D warnings
cargo clippy --package traq-bot-http --all-features -- -D warnings
- name: Format
run: |
cargo fmt --all --check
coverage:
runs-on: ubuntu-latest
Expand All @@ -54,6 +64,7 @@ jobs:
run: |
./grcov . -s . --binary-path ./target/debug/ -t lcov --branch --ignore-not-existing -o ./target/coverage.lcov
- name: Upload coverage to Codecov
if: github.repository_owner == 'H1rono' || github.repository_owner == 'h1rono'
uses: codecov/codecov-action@v4
with:
files: target/coverage.lcov
Expand Down
29 changes: 14 additions & 15 deletions .github/workflows/flake-update.yml → .github/workflows/update.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Update flake lockfile
name: Update cargo lockfile

on:
schedule:
Expand All @@ -14,47 +14,46 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: cachix/install-nix-action@v29
with:
nix_path: "nixpkgs=channel:release-23.05"
- name: Update
run: nix flake update
run: cargo update --workspace
- name: Check diff
id: check-diff
run: |
if git diff --exit-code flake.lock > /dev/null; then
if git diff --exit-code Cargo.lock > /dev/null; then
echo "has_diff=false" >> "$GITHUB_OUTPUT"
else
echo "has_diff=true" >> "$GITHUB_OUTPUT"
fi
update-flake-lock:
update-lockfile:
runs-on: ubuntu-latest
needs: check-update
if: needs.check-update.outputs.has_diff == 'true'
# いつforkされてもいいように
if: >-
needs.check-update.outputs.has_diff == 'true' && (
github.repository_owner == 'H1rono' ||
github.repository_owner == 'h1rono'
)
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: cachix/install-nix-action@v29
with:
nix_path: "nixpkgs=channel:release-23.05"
- name: Update
run: nix flake update
run: cargo update --workspace
- name: git commit and push
run: |
git config user.name "H1rono"
git config user.email "54711422+H1rono@users.noreply.github.com"
BRANCH_NAME="update-$(date +'%Y%m%d%H%M%S')"
git switch -c "$BRANCH_NAME"
git add flake.lock
git commit -m ":arrow_up: CI: update nix flake"
git add Cargo.lock
git commit -m ":arrow_up: CI: update lockfile"
git push origin "$BRANCH_NAME"
- name: Create pull request
run: |
gh pr create --title ":arrow_up: CI: update flake" --body "" --base main --assignee H1rono
gh pr create --title ":arrow_up: CI: update lockfile" --body "" --base main --assignee H1rono
env:
GH_TOKEN: ${{ secrets.PAT }}
18 changes: 9 additions & 9 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: cachix/install-nix-action@v29
with:
nix_path: "nixpkgs=channel:release-23.05"
- name: Validate workflow files
- name: Install cargo-binstall
uses: cargo-bins/cargo-binstall@v1.10.8
- name: Install action-validator
run: cargo +stable binstall --no-confirm action-validator
- name: Lint Actions
run: |
nix develop .#validate -c action-validator .github/workflows/audit.yml
nix develop .#validate -c action-validator .github/workflows/rust.yml
nix develop .#validate -c action-validator .github/workflows/release.yml
nix develop .#validate -c action-validator .github/workflows/validate.yml
nix develop .#validate -c action-validator .github/workflows/flake-update.yml
for file in .github/workflows/*.yml ; do
echo "check $file"
action-validator "$file"
done
- name: Validate codecov.yml
run: |
curl -f --data-binary @codecov.yml https://codecov.io/validate
Expand Down

0 comments on commit 09c29ca

Please sign in to comment.