ci: Use GITHUB_OUTPUT envvar instead of set-output command #1516
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: Go | |
on: # yamllint disable-line rule:truthy | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
outputs: | |
coverage: ${{ steps.coverage.outputs.coverage }} | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: 1.17 | |
- name: Test | |
run: make test | |
- name: Coverage | |
id: coverage | |
run: | | |
make test-create-coverage | |
COVERAGE=$(go tool cover --func=cover.out | grep total | grep -Eo '[0-9]+\.[0-9]+') | |
echo "coverage=${COVERAGE}" >> $GITHUB_OUTPUT | |
- uses: actions/upload-artifact@v2 | |
with: | |
name: test-coverage | |
path: coverage.html | |
- name: Checking generated files are up to date | |
run: | | |
if [[ $(git ls-files --others --exclude-standard) ]]; then git ls-files --others --exclude-standard; echo "These files are not tracked by git"; exit 1; fi | |
if [ -n "$(git status --porcelain)" ]; then echo "There are uncommitted changes:"; git status --short; exit 1; fi | |
Coverage: | |
needs: build | |
name: "Test Coverage ${{ needs.build.outputs.coverage }}" | |
runs-on: ubuntu-latest | |
steps: | |
- run: | | |
echo 'Coverage status: ${{ needs.build.outputs.coverage }}' | |
if [ "$TEST" -lt "80" ]; then echo "Min coverage failed"; exit 1; fi | |
Lint: | |
name: Lint code | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v2 | |
- name: Run golangci-lint | |
uses: golangci/[email protected] | |
with: | |
args: --timeout=2m | |
YamlLint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: ⤵️ Check out code from GitHub | |
uses: actions/checkout@v2 | |
- name: 🚀 Run yamllint | |
run: | | |
yamllint -f github -c .yamllint . | |
Security-Scanner: | |
name: Security Scanner | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v2 | |
- name: Run Gosec Security Scanner | |
uses: securego/gosec@master | |
env: | |
GOFLAGS: -buildvcs=false | |
with: | |
args: '-exclude-generated ./...' |