Skip to content

Commit

Permalink
rust-cacheの導入: PR作成時とmainへのpush時に動くワークフローにSwatinem/rust-cacheを導入 (#332
Browse files Browse the repository at this point in the history
)

* update: rust-cache: PR作成時とmainへのpush時に動くワークフローに`Swatinem/rust-cache@v2`を追加
* update: rust-cache: `python-build-check.yaml`をmainブランチにコミットが追加された際も動くように設定し、その際にキャッシュを保存するように設定
  • Loading branch information
YuukiToriyama authored Jul 5, 2024
1 parent d3f6f44 commit e160368
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/code-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
cache-all-crates: true
shared-key: 'test-on-pr'
save-if: ${{ github.ref == 'refs/heads/main' }} # mainブランチにコミットが追加された時のみキャッシュを保存する
cache-provider: 'github'
- name: Set up clippy
run: rustup component add clippy
- name: Code review with clippy
Expand Down
29 changes: 26 additions & 3 deletions .github/workflows/python-build-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Python module build check

on:
pull_request:
push:
branches: [ 'main' ]

permissions:
contents: read
Expand All @@ -11,6 +13,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
cache-all-crates: true
shared-key: 'maturin-linux'
save-if: ${{ github.ref == 'refs/heads/main' }} # mainブランチにコミットが追加された時のみキャッシュを保存する
cache-provider: 'github'
- uses: actions/setup-python@v5
with:
python-version: '3.10'
Expand All @@ -20,13 +28,18 @@ jobs:
target: x86_64
args: --release --out dist --zig
working-directory: python
sccache: 'true'
manylinux: auto

windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
cache-all-crates: true
shared-key: 'maturin-windows'
save-if: ${{ github.ref == 'refs/heads/main' }} # mainブランチにコミットが追加された時のみキャッシュを保存する
cache-provider: 'github'
- uses: actions/setup-python@v5
with:
python-version: '3.10'
Expand All @@ -37,12 +50,17 @@ jobs:
target: x64
args: --release --out dist
working-directory: python
sccache: 'true'

macos:
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
cache-all-crates: true
shared-key: 'maturin-macos'
save-if: ${{ github.ref == 'refs/heads/main' }} # mainブランチにコミットが追加された時のみキャッシュを保存する
cache-provider: 'github'
- uses: actions/setup-python@v5
with:
python-version: '3.10'
Expand All @@ -52,12 +70,17 @@ jobs:
target: aarch64
args: --release --out dist
working-directory: python
sccache: 'true'

sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
cache-all-crates: true
shared-key: 'maturin-sdist'
save-if: ${{ github.ref == 'refs/heads/main' }} # mainブランチにコミットが追加された時のみキャッシュを保存する
cache-provider: 'github'
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/wasm-pack-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
cache-all-crates: true
shared-key: 'wasm-pack'
save-if: ${{ github.ref == 'refs/heads/main' }} # mainブランチにコミットが追加された時のみキャッシュを保存する
cache-provider: 'github'
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Unit test for core module
Expand Down

0 comments on commit e160368

Please sign in to comment.