2019-10-18 14:39:22 +00:00
|
|
|
---
|
|
|
|
name: build
|
|
|
|
|
2020-05-01 03:31:59 +00:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
pull_request:
|
|
|
|
repository_dispatch:
|
|
|
|
types: [apb]
|
2019-10-18 14:39:22 +00:00
|
|
|
|
2020-03-04 13:41:59 +00:00
|
|
|
env:
|
|
|
|
PIP_CACHE_DIR: ~/.cache/pip
|
|
|
|
PRE_COMMIT_CACHE_DIR: ~/.cache/pre-commit
|
|
|
|
|
2019-10-18 14:39:22 +00:00
|
|
|
jobs:
|
2020-04-06 23:02:31 +00:00
|
|
|
lint:
|
2019-10-18 14:39:22 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2022-02-28 05:32:42 +00:00
|
|
|
- id: setup-env
|
|
|
|
uses: cisagov/setup-env-github-action@develop
|
2022-03-07 18:01:37 +00:00
|
|
|
- uses: actions/checkout@v3
|
2020-11-11 03:10:38 +00:00
|
|
|
- id: setup-python
|
2022-11-08 20:06:28 +00:00
|
|
|
uses: actions/setup-python@v4
|
2019-10-18 14:39:22 +00:00
|
|
|
with:
|
2021-12-15 20:02:34 +00:00
|
|
|
python-version: "3.10"
|
2022-02-28 05:32:42 +00:00
|
|
|
# We need the Go version and Go cache location for the actions/cache step,
|
|
|
|
# so the Go installation must happen before that.
|
2022-05-27 22:04:15 +00:00
|
|
|
- id: setup-go
|
|
|
|
uses: actions/setup-go@v3
|
2022-02-28 05:32:42 +00:00
|
|
|
with:
|
2022-11-08 18:27:47 +00:00
|
|
|
go-version: "1.19"
|
2022-02-28 05:32:42 +00:00
|
|
|
- name: Lookup Go cache directory
|
|
|
|
id: go-cache
|
|
|
|
run: |
|
2022-10-11 14:57:16 +00:00
|
|
|
echo "dir=$(go env GOCACHE)" >> $GITHUB_OUTPUT
|
2022-04-01 16:22:39 +00:00
|
|
|
- uses: actions/cache@v3
|
2020-11-20 17:22:39 +00:00
|
|
|
env:
|
|
|
|
BASE_CACHE_KEY: "${{ github.job }}-${{ runner.os }}-\
|
2022-02-28 05:32:42 +00:00
|
|
|
py${{ steps.setup-python.outputs.python-version }}-\
|
2022-11-09 16:35:10 +00:00
|
|
|
go${{ steps.setup-go.outputs.go-version }}-"
|
2019-11-05 19:27:20 +00:00
|
|
|
with:
|
2020-07-30 06:19:02 +00:00
|
|
|
path: |
|
|
|
|
${{ env.PIP_CACHE_DIR }}
|
|
|
|
${{ env.PRE_COMMIT_CACHE_DIR }}
|
2022-02-28 05:32:42 +00:00
|
|
|
${{ steps.go-cache.outputs.dir }}
|
2020-11-20 17:22:39 +00:00
|
|
|
key: "${{ env.BASE_CACHE_KEY }}\
|
2020-02-12 05:14:11 +00:00
|
|
|
${{ hashFiles('**/.pre-commit-config.yaml') }}"
|
2020-07-30 06:19:02 +00:00
|
|
|
restore-keys: |
|
2020-11-20 17:22:39 +00:00
|
|
|
${{ env.BASE_CACHE_KEY }}
|
2022-02-28 05:32:42 +00:00
|
|
|
- name: Install shfmt
|
|
|
|
env:
|
|
|
|
PACKAGE_URL: mvdan.cc/sh/v3/cmd/shfmt
|
|
|
|
PACKAGE_VERSION: ${{ steps.setup-env.outputs.shfmt-version }}
|
|
|
|
run: go install ${PACKAGE_URL}@${PACKAGE_VERSION}
|
2019-10-18 14:39:22 +00:00
|
|
|
- name: Install dependencies
|
|
|
|
run: |
|
2021-12-15 20:02:34 +00:00
|
|
|
python -m pip install --upgrade pip setuptools wheel
|
|
|
|
pip install --upgrade pre-commit
|
2020-04-06 23:02:31 +00:00
|
|
|
- name: Set up pre-commit hook environments
|
2020-04-06 17:47:18 +00:00
|
|
|
run: pre-commit install-hooks
|
2019-10-18 14:39:22 +00:00
|
|
|
- name: Run pre-commit on all files
|
|
|
|
run: pre-commit run --all-files
|