1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
name: Run static checks
on:
workflow_call:
inputs:
runs-on:
description: 'A tag to indicate which runner to use'
required: true
type: string
gochannel:
description: 'The snap store channel to use to install the go snap'
required: true
type: string
jobs:
static-checks:
runs-on: ${{ inputs.runs-on }}
env:
# Set PATH to ignore the load of magic binaries from /usr/local/bin And
# to use the go snap automatically. Note that we install go from the
# snap in a step below. Without this we get the GitHub-controlled latest
# version of go.
PATH: /snap/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:${{ github.workspace }}/bin
GOROOT: ""
GITHUB_PULL_REQUEST_TITLE: ${{ github.event.pull_request.title }}
BASE_REF: ${{ github.base_ref }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
# needed for git commit history
fetch-depth: 0
# Fetch base ref, needed for golangci-lint
- name: Fetching base ref ${{ github.base_ref }}
run: |
git fetch origin ${{ github.base_ref }}:${{ github.base_ref }}
- name: Download and install Debian dependencies
# Github does not allow variables in "uses"; this has to be a hard-coded path
uses: ./.github/actions/download-install-debian-deps
with:
snapd-src-dir: "${{ github.workspace }}"
# golang latest ensures things work on the edge
- name: Install the go snap
run: |
sudo snap install --classic --channel=${{ inputs.gochannel }} go
- name: Install ShellCheck as a snap
run: |
sudo apt-get remove --purge shellcheck
sudo snap install shellcheck
- name: Get C vendoring
run: |
cd c-vendor && ./vendor.sh
- name: Install golangci-lint snap
run: |
sudo snap install --classic golangci-lint
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46.0.5
- name: Save changes files
run: |
CHANGED_FILES="${{ steps.changed-files.outputs.all_changed_files }}"
echo "CHANGED_FILES=$CHANGED_FILES" >> $GITHUB_ENV
echo "The changed files found are: $CHANGED_FILES"
- name: Run static checks
run: |
# run gofmt checks only with the latest stable Go
if [ "${{ matrix.gochannel }}" != "latest/stable" ]; then
export SKIP_GOFMT=1
echo "Formatting checks will be skipped due to the use of Go version ${{ inputs.gochannel }}"
fi
sudo apt-get install -y python3-yamlordereddictloader
./run-checks --static
|