Files
firezone/.github/workflows/static-analysis.yml
Jamil 2a99cc39e9 Install and cache Rust toolchain (#2353)
On GH-hosted runners, this isn't a problem. But on self-hosted runners
with persistent disks, we hit this issue:
https://github.com/Swatinem/rust-cache#known-issues

This PR should fix that by ensuring the Rust toolchain is installed. It
also installs the toolchain after the cache has been restored so we can
take advantage of any cached artifacts.
2023-10-16 11:16:18 -06:00

55 lines
1.7 KiB
YAML

name: Static Analysis
on:
workflow_call:
jobs:
version-check:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
workspaces: ./rust
key: ubuntu-22.04-${{ runner.arch }}
save-if: ${{ github.ref == 'refs/heads/main' }}
- uses: dtolnay/rust-toolchain@stable
- name: Check version is up to date
run: |
make version
if [ -z "$(git status --porcelain)" ]; then
# Working directory clean
echo "Version manifests up to date"
else
# Uncommitted changes
echo '`make version` found outdated files! Showing diff'
git diff
exit 1
fi
global-linter:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.9"
- uses: actions/cache/restore@v3
name: Restore Python Cache
with:
path: ~/.cache/pip
key: ubuntu-22.04-${{ runner.arch }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
ubuntu-22.04-${{ runner.arch }}-pip-
- name: Install Python Dependencies
run: |
pip install -r requirements.txt
- name: Run pre-commit
run: |
pre-commit install
SKIP=no-commit-to-branch pre-commit run --all-files
- uses: actions/cache/save@v3
if: ${{ github.ref == 'refs/heads/main' }}
name: Save Python Cache
with:
path: ~/.cache/pip
key: ubuntu-22.04-${{ runner.arch }}-pip-${{ hashFiles('requirements.txt') }}