🏪 Build Template #939
This file contains 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
name: 🏪 Build Template | |
on: | |
schedule: | |
- cron: '0 0 * * *' | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ '*' ] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
changes: | |
runs-on: ubuntu-latest | |
permissions: | |
pull-requests: read | |
outputs: | |
axum: ${{ steps.filter.outputs.axum }} | |
docker: ${{ steps.filter.outputs.docker }} | |
examples: ${{ steps.filter.outputs.examples }} | |
nix: ${{ steps.filter.outputs.nix }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- uses: dorny/paths-filter@v2 | |
id: filter | |
with: | |
filters: | | |
axum: | |
- 'rust/src.axum/**' | |
- 'rust+wasm/{{project-name}}/src.axum/**' | |
docker: | |
- 'rust/Dockerfile.*' | |
- 'rust/Dockerfile.*' | |
- 'rust+wasm/docker/**' | |
examples: | |
- 'examples/**' | |
nix: | |
- 'rust/flake.nix' | |
- 'rust+wasm/flake.nix' | |
nix-flake-check: | |
needs: changes | |
if: ${{ needs.changes.outputs.nix == 'true' || github.event_name != 'pull_request' }} | |
runs-on: ubuntu-latest | |
env: | |
## force it last for cargo-sort | |
PROJECT_NAME: fission-codes-rust-template | |
strategy: | |
fail-fast: false | |
matrix: | |
templates: | |
- rust | |
- rust+wasm | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup cargo-generate | |
uses: cargo-generate/cargo-generate-action@v0.18.3 | |
with: | |
name: ${{ env.PROJECT_NAME }} | |
subfolder: ${{ matrix.templates }} | |
template_values_file: .github/workflows/template_values.toml | |
other: "--lib" | |
- name: Install Nix | |
uses: cachix/install-nix-action@v23 | |
with: | |
extra_nix_config: | | |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} | |
- name: Nix Flake/Develop Checks - Rust Template | |
if: ${{ matrix.templates == 'rust' }} | |
run: | | |
mv $PROJECT_NAME ${{ runner.temp }}/ | |
cd ${{ runner.temp }}/$PROJECT_NAME | |
git init | |
git add . | |
nix flake check | |
nix develop --show-trace -c rustc --version | |
nix develop --show-trace -c cargo udeps --version | |
nix develop --show-trace -c irust --version | |
nix develop --show-trace -c pre-commit --version | |
nix develop --show-trace -c alejandra --version | |
- name: Nix Flake/Develop Checks - Rust+Wasm Template | |
if: ${{ matrix.templates == 'rust+wasm' }} | |
run: | | |
mv $PROJECT_NAME ${{ runner.temp }}/ | |
cd ${{ runner.temp }}/$PROJECT_NAME | |
git init | |
git add . | |
nix flake check | |
nix develop --show-trace -c rustc --version | |
nix develop --show-trace -c wasm-pack --version | |
run-pre-commit: | |
runs-on: ubuntu-latest | |
env: | |
## force it last for cargo-sort | |
PROJECT_NAME: zfission-codes-rust-template | |
strategy: | |
fail-fast: false | |
matrix: | |
templates: | |
- rust | |
- rust+wasm | |
crate_type: | |
- lib | |
- bin | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup cargo-generate | |
uses: cargo-generate/cargo-generate-action@v0.18.3 | |
with: | |
name: ${{ env.PROJECT_NAME }} | |
subfolder: ${{ matrix.templates }} | |
template_values_file: .github/workflows/template_values.toml | |
other: "--${{ matrix.crate_type }}" | |
- name: Install Rust Toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
override: true | |
profile: minimal | |
toolchain: stable | |
- name: Install Rust-Nighly Toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
override: true | |
profile: minimal | |
components: rustfmt | |
toolchain: nightly | |
- name: Install Cargo Audit | |
uses: actions-rs/cargo@v1 | |
with: | |
args: --force cargo-deny | |
command: install | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
- name: Install pre-commit | |
run: pip install pre-commit | |
- name: Install pre-commit Hooks | |
run: pre-commit install | |
- name: Install Nix | |
uses: cachix/install-nix-action@v23 | |
with: | |
extra_nix_config: | | |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} | |
# move generated project to temp folder: | |
# https://github.com/rust-lang/cargo/issues/9922 | |
- name: Run Cargo-check & then pre-commit (Lint, Fmt, Deny) on All Files | |
run: | | |
mv $PROJECT_NAME ${{ runner.temp }}/ | |
cd ${{ runner.temp }}/$PROJECT_NAME | |
git init | |
git add . | |
nix profile install github:kamadorueda/alejandra/3.0.0 | |
cargo check | |
cargo deny check | |
pre-commit run --all-files --show-diff-on-failure | |
run-pre-commit-axum: | |
needs: changes | |
if: ${{ needs.changes.outputs.axum == 'true' || github.event_name != 'pull_request' }} | |
runs-on: ubuntu-latest | |
env: | |
## force it last for cargo-sort | |
PROJECT_NAME: zzfission-codes-rust-template | |
strategy: | |
fail-fast: false | |
matrix: | |
templates: | |
- rust | |
- rust+wasm | |
steps: | |
- name: Install Protoc | |
uses: arduino/setup-protoc@v2 | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup cargo-generate | |
uses: cargo-generate/cargo-generate-action@v0.18.3 | |
with: | |
name: ${{ env.PROJECT_NAME }} | |
subfolder: ${{ matrix.templates }} | |
template_values_file: .github/workflows/template_values.toml | |
other: "--bin -d axum=true" | |
- name: Install Rust Toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
override: true | |
profile: minimal | |
toolchain: stable | |
- name: Install Rust-Nighly Toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
override: true | |
profile: minimal | |
components: rustfmt | |
toolchain: nightly | |
- name: Install Cargo Audit | |
uses: actions-rs/cargo@v1 | |
with: | |
args: --force cargo-deny | |
command: install | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
- name: Install pre-commit | |
run: pip install pre-commit | |
- name: Install pre-commit Hooks | |
run: pre-commit install | |
- name: Install Nix | |
uses: cachix/install-nix-action@v23 | |
with: | |
extra_nix_config: | | |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} | |
- name: Run Cargo-check & then pre-commit (Lint, Fmt, Deny) on All Files | |
run: | | |
mv $PROJECT_NAME ${{ runner.temp }}/ | |
cd ${{ runner.temp }}/$PROJECT_NAME | |
git init | |
git add . | |
nix profile install github:kamadorueda/alejandra/3.0.0 | |
cargo check | |
cargo deny check | |
pre-commit run --all-files --show-diff-on-failure | |
test-rust-project: | |
runs-on: ubuntu-latest | |
env: | |
PROJECT_NAME: fission-codes-rust-template | |
strategy: | |
fail-fast: false | |
matrix: | |
crate_type: | |
- lib | |
- bin | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Setup cargo-generate | |
uses: cargo-generate/cargo-generate-action@v0.18.3 | |
with: | |
name: ${{ env.PROJECT_NAME }} | |
subfolder: rust | |
template_values_file: .github/workflows/template_values.toml | |
other: "--${{ matrix.crate_type }}" | |
- name: Install Rust Toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
override: true | |
toolchain: stable | |
- name: Run Tests | |
run: | | |
mv $PROJECT_NAME ${{ runner.temp }}/ | |
cd ${{ runner.temp }}/$PROJECT_NAME | |
cargo test --all-features | |
test-rust-axum-project: | |
needs: changes | |
if: ${{ needs.changes.outputs.axum == 'true' || github.event_name != 'pull_request' }} | |
runs-on: ubuntu-latest | |
env: | |
PROJECT_NAME: fission-codes-rust-template | |
steps: | |
- name: Install Protoc | |
uses: arduino/setup-protoc@v2 | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Setup cargo-generate | |
uses: cargo-generate/cargo-generate-action@v0.18.3 | |
with: | |
name: ${{ env.PROJECT_NAME }} | |
subfolder: rust | |
template_values_file: .github/workflows/template_values.toml | |
other: "--bin -d axum=true" | |
- name: Install Rust Toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
override: true | |
toolchain: stable | |
- name: Run Tests | |
run: | | |
mv $PROJECT_NAME ${{ runner.temp }}/ | |
cd ${{ runner.temp }}/$PROJECT_NAME | |
cargo build --bin openapi | |
cargo test --all-features | |
test-rust-wasm-project: | |
runs-on: ubuntu-latest | |
env: | |
PROJECT_NAME: fission-codes-rust-template | |
strategy: | |
fail-fast: false | |
matrix: | |
crate_type: | |
- lib | |
- bin | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Setup cargo-generate | |
uses: cargo-generate/cargo-generate-action@v0.18.3 | |
with: | |
name: ${{ env.PROJECT_NAME }} | |
subfolder: rust+wasm | |
template_values_file: .github/workflows/template_values.toml | |
other: "--${{ matrix.crate_type }}" | |
- name: Install Rust Toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
override: true | |
toolchain: stable | |
- name: Install wasm-pack | |
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | |
- name: Run Tests | |
run: | | |
mv $PROJECT_NAME ${{ runner.temp }}/ | |
cd ${{ runner.temp }}/$PROJECT_NAME/$PROJECT_NAME | |
cargo test --all-features | |
cd ../$PROJECT_NAME-wasm | |
wasm-pack test --headless --firefox --chrome | |
test-rust-wasm-axum-project: | |
needs: changes | |
if: ${{ needs.changes.outputs.axum == 'true' || github.event_name != 'pull_request' }} | |
runs-on: ubuntu-latest | |
env: | |
PROJECT_NAME: fission-codes-rust-template | |
steps: | |
- name: Install Protoc | |
uses: arduino/setup-protoc@v2 | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Setup cargo-generate | |
uses: cargo-generate/cargo-generate-action@v0.18.3 | |
with: | |
name: ${{ env.PROJECT_NAME }} | |
subfolder: rust+wasm | |
template_values_file: .github/workflows/template_values.toml | |
other: "--bin -d axum=true" | |
- name: Install Rust Toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
override: true | |
toolchain: stable | |
- name: Install wasm-pack | |
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | |
- name: Run Tests | |
run: | | |
mv $PROJECT_NAME ${{ runner.temp }}/ | |
cd ${{ runner.temp }}/$PROJECT_NAME/$PROJECT_NAME | |
cargo test --all-features | |
cargo build --bin openapi | |
cd ../$PROJECT_NAME-wasm | |
wasm-pack test --headless --firefox --chrome | |
test-benchmark: | |
runs-on: ubuntu-latest | |
env: | |
PROJECT_NAME: fission-codes-rust-template | |
strategy: | |
fail-fast: false | |
matrix: | |
templates: | |
- rust | |
- rust+wasm | |
crate_type: | |
- lib | |
- bin | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Setup cargo-generate | |
uses: cargo-generate/cargo-generate-action@v0.18.3 | |
with: | |
name: ${{ env.PROJECT_NAME }} | |
subfolder: ${{ matrix.templates }} | |
template_values_file: .github/workflows/template_values.toml | |
other: "--${{ matrix.crate_type }}" | |
- name: Install Rust Toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
override: true | |
toolchain: stable | |
- name: Run Benchmark - Rust Template | |
if: ${{ matrix.templates == 'rust' }} | |
run: | | |
mv $PROJECT_NAME ${{ runner.temp }}/ | |
cd ${{ runner.temp }}/$PROJECT_NAME | |
cargo bench --all-features -- --output-format bencher | tee output.txt | |
- name: Run Benchmark - Rust+Wasm Template | |
if: ${{ matrix.templates == 'rust+wasm' }} | |
run: | | |
mv $PROJECT_NAME ${{ runner.temp }}/ | |
cd ${{ runner.temp }}/$PROJECT_NAME | |
cargo bench -p $PROJECT_NAME-benches -- --output-format bencher | tee output.txt | |
test-benchmark-axum: | |
needs: changes | |
if: ${{ needs.changes.outputs.axum == 'true' || github.event_name != 'pull_request' }} | |
runs-on: ubuntu-latest | |
env: | |
PROJECT_NAME: fission-codes-rust-template | |
strategy: | |
fail-fast: false | |
matrix: | |
templates: | |
- rust | |
- rust+wasm | |
steps: | |
- name: Install Protoc | |
uses: arduino/setup-protoc@v2 | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Setup cargo-generate | |
uses: cargo-generate/cargo-generate-action@v0.18.3 | |
with: | |
name: ${{ env.PROJECT_NAME }} | |
subfolder: ${{ matrix.templates }} | |
template_values_file: .github/workflows/template_values.toml | |
other: "--bin -d axum=true" | |
- name: Install Rust Toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
override: true | |
toolchain: stable | |
- name: Run Benchmark - Rust Template | |
if: ${{ matrix.templates == 'rust' }} | |
run: | | |
mv $PROJECT_NAME ${{ runner.temp }}/ | |
cd ${{ runner.temp }}/$PROJECT_NAME | |
cargo bench --all-features -- --output-format bencher | tee output.txt | |
- name: Run Benchmark - Rust+Wasm Template | |
if: ${{ matrix.templates == 'rust+wasm' }} | |
run: | | |
mv $PROJECT_NAME ${{ runner.temp }}/ | |
cd ${{ runner.temp }}/$PROJECT_NAME | |
cargo bench -p $PROJECT_NAME-benches -- --output-format bencher | tee output.txt | |
test-docker: | |
needs: changes | |
if: ${{ needs.changes.outputs.docker == 'true' || github.event_name != 'pull_request' }} | |
runs-on: ubuntu-latest | |
env: | |
PROJECT_NAME: fission-codes-rust-template | |
strategy: | |
fail-fast: false | |
matrix: | |
templates: | |
- rust | |
- rust+wasm | |
dockerbuild: | |
- glibc | |
- musl | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Setup cargo-generate | |
uses: cargo-generate/cargo-generate-action@v0.18.3 | |
with: | |
name: ${{ env.PROJECT_NAME }} | |
subfolder: ${{ matrix.templates }} | |
template_values_file: .github/workflows/template_values.toml | |
other: "--bin -d docker=true -d dockerbuild=${{ matrix.dockerbuild }}" | |
- name: Setup QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Setup Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
buildkitd-flags: "--debug" | |
- name: Docker Build MUSL - Rust Template | |
if: ${{ matrix.dockerbuild == 'musl' && matrix.templates == 'rust' }} | |
run: | | |
mv $PROJECT_NAME ${{ runner.temp }}/ | |
cd ${{ runner.temp }}/$PROJECT_NAME | |
docker buildx build \ | |
--cache-from type=gha --cache-to type=gha,mode=max \ | |
--platform=linux/amd64,linux/arm64 \ | |
--tag $PROJECT_NAME:latest . | |
- name: Docker Build MUSL - Rust+Wasm Template | |
if: ${{ matrix.dockerbuild == 'musl' && matrix.templates == 'rust+wasm' }} | |
run: | | |
mv $PROJECT_NAME ${{ runner.temp }}/ | |
cd ${{ runner.temp }}/$PROJECT_NAME | |
docker buildx build \ | |
--cache-from type=gha --cache-to type=gha,mode=max \ | |
--platform=linux/amd64,linux/arm64 \ | |
--tag $PROJECT_NAME:latest \ | |
--file docker/Dockerfile . | |
- name: Docker Build GLIBC - Rust Template | |
if: ${{ matrix.dockerbuild == 'glibc' && matrix.templates == 'rust' }} | |
run: | | |
mv $PROJECT_NAME ${{ runner.temp }}/ | |
cd ${{ runner.temp }}/$PROJECT_NAME | |
docker buildx build \ | |
--cache-from type=gha --cache-to type=gha,mode=max \ | |
--platform=linux/amd64 \ | |
--tag $PROJECT_NAME:latest . | |
- name: Docker Build GLIBC - Rust+Wasm Template | |
if: ${{ matrix.dockerbuild == 'glibc' && matrix.templates == 'rust+wasm' }} | |
run: | | |
mv $PROJECT_NAME ${{ runner.temp }}/ | |
cd ${{ runner.temp }}/$PROJECT_NAME | |
docker buildx build \ | |
--cache-from type=gha --cache-to type=gha,mode=max \ | |
--platform=linux/amd64 \ | |
--tag $PROJECT_NAME:latest \ | |
--file docker/Dockerfile . | |
test-docker-axum: | |
needs: changes | |
if: ${{ needs.changes.outputs.docker == 'true' || github.event_name != 'pull_request' }} | |
runs-on: ubuntu-latest | |
env: | |
PROJECT_NAME: fission-codes-rust-template | |
strategy: | |
fail-fast: false | |
matrix: | |
templates: | |
- rust | |
- rust+wasm | |
dockerbuild: | |
- glibc | |
- musl | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Setup cargo-generate | |
uses: cargo-generate/cargo-generate-action@v0.18.3 | |
with: | |
name: ${{ env.PROJECT_NAME }} | |
subfolder: ${{ matrix.templates }} | |
template_values_file: .github/workflows/template_values.toml | |
other: "--bin -d docker=true -d dockerbuild=${{ matrix.dockerbuild }} -d axum=true" | |
- name: Setup QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Setup Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
buildkitd-flags: "--debug" | |
- name: Docker Build MUSL - Rust Template | |
if: ${{ matrix.dockerbuild == 'musl' && matrix.templates == 'rust' }} | |
run: | | |
mv $PROJECT_NAME ${{ runner.temp }}/ | |
cd ${{ runner.temp }}/$PROJECT_NAME | |
docker buildx build \ | |
--cache-from type=gha --cache-to type=gha,mode=max \ | |
--platform=linux/amd64,linux/arm64 \ | |
--tag $PROJECT_NAME:latest . | |
- name: Docker Build MUSL - Rust+Wasm Template | |
if: ${{ matrix.dockerbuild == 'musl' && matrix.templates == 'rust+wasm' }} | |
run: | | |
mv $PROJECT_NAME ${{ runner.temp }}/ | |
cd ${{ runner.temp }}/$PROJECT_NAME | |
docker buildx build \ | |
--cache-from type=gha --cache-to type=gha,mode=max \ | |
--platform=linux/amd64,linux/arm64 \ | |
--tag $PROJECT_NAME:latest \ | |
--file docker/Dockerfile . | |
- name: Docker Build GLIBC - Rust Template | |
if: ${{ matrix.dockerbuild == 'glibc' && matrix.templates == 'rust' }} | |
run: | | |
mv $PROJECT_NAME ${{ runner.temp }}/ | |
cd ${{ runner.temp }}/$PROJECT_NAME | |
docker buildx build \ | |
--cache-from type=gha --cache-to type=gha,mode=max \ | |
--platform=linux/amd64 \ | |
--tag $PROJECT_NAME:latest . | |
- name: Docker Build GLIBC - Rust+Wasm Template | |
if: ${{ matrix.dockerbuild == 'glibc' && matrix.templates == 'rust+wasm' }} | |
run: | | |
mv $PROJECT_NAME ${{ runner.temp }}/ | |
cd ${{ runner.temp }}/$PROJECT_NAME | |
docker buildx build \ | |
--cache-from type=gha --cache-to type=gha,mode=max \ | |
--platform=linux/amd64 \ | |
--tag $PROJECT_NAME:latest \ | |
--file docker/Dockerfile . | |
run-examples: | |
needs: changes | |
if: ${{ needs.changes.outputs.examples == 'true' || github.event_name != 'pull_request' }} | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
example: | |
- gen-axum | |
defaults: | |
run: | |
working-directory: examples | |
steps: | |
- name: Install Protoc | |
uses: arduino/setup-protoc@v2 | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Cache Project | |
uses: Swatinem/rust-cache@v2 | |
- name: Install Rust Toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
override: true | |
toolchain: stable | |
- name: Run Examples | |
shell: bash | |
run: | | |
cargo build -p ${{ matrix.example }} --all-features | |
timeout 30s cargo run -p ${{ matrix.example }} --all-features || code=$?; if [[ $code -ne 124 && $code -ne 0 ]]; then exit $code; fi |