feat(action): add GitHub Action #111
Workflow file for this run
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
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
schedule: | |
# run every morning at 10am Pacific Time | |
- cron: '0 17 * * *' | |
name: ci | |
env: | |
CARGO_INCREMENTAL: 0 | |
CARGO_NET_RETRY: 10 | |
RUSTUP_MAX_RETRIES: 10 | |
RUST_BACKTRACE: 1 | |
# Pin the nightly toolchain to prevent breakage. | |
# This should be occasionally updated. | |
RUST_NIGHTLY_TOOLCHAIN: nightly-2024-10-07 | |
jobs: | |
env: | |
runs-on: ubuntu-latest | |
outputs: | |
rust-versions: ${{ steps.definitions.outputs.versions }} | |
msrv: ${{ steps.definitions.outputs.msrv }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Evaluate definitions | |
id: definitions | |
run: | | |
export MSRV=$(cat rust-toolchain | awk '{$1=$1};1') | |
echo "msrv=$MSRV" >> "$GITHUB_OUTPUT" | |
export RAW_VERSIONS="stable beta $RUST_NIGHTLY_TOOLCHAIN $MSRV" | |
export VERSIONS=$(echo $RAW_VERSIONS | jq -scR 'rtrimstr("\n")|split(" ")|.') | |
echo "versions=$VERSIONS" >> "$GITHUB_OUTPUT" | |
rustfmt: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions-rs/toolchain@v1 | |
id: toolchain | |
with: | |
toolchain: ${{ env.RUST_NIGHTLY_TOOLCHAIN }} | |
profile: minimal | |
override: true | |
components: rustfmt | |
- name: Run cargo fmt | |
uses: actions-rs/cargo@v1 | |
with: | |
command: fmt | |
args: --all -- --check | |
clippy: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- toolchain: stable | |
# fail on stable warnings | |
args: "-D warnings" | |
- toolchain: beta | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- uses: actions-rs/[email protected] | |
id: toolchain | |
with: | |
toolchain: ${{ matrix.toolchain }} | |
profile: minimal | |
override: true | |
components: clippy | |
- uses: camshaft/rust-cache@v1 | |
- name: Cache node_modules | |
uses: actions/[email protected] | |
continue-on-error: true | |
with: | |
path: www/node_modules | |
key: node-modules-${{ runner.os }}-${{ hashFiles('www/package-lock.json') }} | |
- name: Build script.js | |
run: | | |
make www/public/script.js | |
# TODO translate json reports to in-action warnings | |
- name: Run cargo clippy | |
uses: actions-rs/[email protected] | |
with: | |
command: clippy | |
args: --all-features --all-targets -- -A clippy::uninlined_format_args ${{ matrix.args }} | |
udeps: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- uses: actions-rs/[email protected] | |
id: toolchain | |
with: | |
toolchain: ${{ env.RUST_NIGHTLY_TOOLCHAIN }} | |
profile: minimal | |
override: true | |
- uses: camshaft/rust-cache@v1 | |
- uses: camshaft/install@v1 | |
with: | |
crate: cargo-udeps | |
- name: Cache node_modules | |
uses: actions/[email protected] | |
continue-on-error: true | |
with: | |
path: www/node_modules | |
key: node-modules-${{ runner.os }}-${{ hashFiles('www/package-lock.json') }} | |
- name: Build script.js | |
run: | | |
make www/public/script.js | |
- name: Run cargo udeps | |
run: cargo udeps --workspace --all-targets | |
env: | |
RUSTC_WRAPPER: "" | |
test: | |
runs-on: ${{ matrix.os }} | |
needs: env | |
strategy: | |
matrix: | |
rust: ${{ fromJson(needs.env.outputs.rust-versions) }} | |
os: [ubuntu-latest, macOS-latest] | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
lfs: true | |
- uses: actions-rs/toolchain@v1 | |
id: toolchain | |
with: | |
toolchain: ${{ matrix.rust }} | |
override: true | |
- uses: camshaft/rust-cache@v1 | |
with: | |
key: ${{ matrix.target }} | |
- name: Cache node_modules | |
uses: actions/[email protected] | |
continue-on-error: true | |
with: | |
path: www/node_modules | |
key: node-modules-${{ runner.os }}-${{ hashFiles('www/package-lock.json') }} | |
- name: Build script.js | |
run: | | |
make www/public/script.js | |
- name: Run cargo test | |
uses: actions-rs/cargo@v1 | |
with: | |
command: test | |
action: # make sure the action works on a clean machine without building | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: ./ |