mirror of
https://github.com/lukaszraczylo/shared-actions.git
synced 2026-07-07 06:34:24 +00:00
Split checks to run in parallel.
This commit is contained in:
@@ -21,10 +21,9 @@ on:
|
|||||||
# security-events: write
|
# security-events: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
pr-checks:
|
static-analysis:
|
||||||
name: PR Checks
|
name: Static Analysis
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -37,11 +36,8 @@ jobs:
|
|||||||
go-version: ${{ inputs.go-version }}
|
go-version: ${{ inputs.go-version }}
|
||||||
cache: true
|
cache: true
|
||||||
|
|
||||||
- name: Install tools
|
- name: Install staticcheck
|
||||||
run: |
|
run: go install honnef.co/go/tools/cmd/staticcheck@latest
|
||||||
go install honnef.co/go/tools/cmd/staticcheck@latest
|
|
||||||
go install golang.org/x/vuln/cmd/govulncheck@latest
|
|
||||||
go install github.com/securego/gosec/v2/cmd/gosec@latest
|
|
||||||
|
|
||||||
- name: Run go vet
|
- name: Run go vet
|
||||||
run: go vet ./...
|
run: go vet ./...
|
||||||
@@ -49,17 +45,52 @@ jobs:
|
|||||||
- name: Run staticcheck
|
- name: Run staticcheck
|
||||||
run: staticcheck ./...
|
run: staticcheck ./...
|
||||||
|
|
||||||
|
security-scan:
|
||||||
|
name: Security Scan
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Setup Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: ${{ inputs.go-version }}
|
||||||
|
cache: true
|
||||||
|
|
||||||
- name: Run TruffleHog
|
- name: Run TruffleHog
|
||||||
uses: trufflesecurity/trufflehog@main
|
uses: trufflesecurity/trufflehog@main
|
||||||
with:
|
with:
|
||||||
extra_args: --only-verified
|
extra_args: --only-verified
|
||||||
|
|
||||||
|
- name: Install govulncheck
|
||||||
|
run: go install golang.org/x/vuln/cmd/govulncheck@latest
|
||||||
|
|
||||||
- name: Run govulncheck
|
- name: Run govulncheck
|
||||||
run: govulncheck ./...
|
run: govulncheck ./...
|
||||||
|
|
||||||
|
gosec:
|
||||||
|
name: Gosec SARIF
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Setup Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: ${{ inputs.go-version }}
|
||||||
|
cache: true
|
||||||
|
|
||||||
|
- name: Install gosec
|
||||||
|
run: go install github.com/securego/gosec/v2/cmd/gosec@latest
|
||||||
|
|
||||||
- name: Run gosec
|
- name: Run gosec
|
||||||
run: |
|
run: gosec -no-fail -fmt sarif -out gosec-results.sarif ./... || true
|
||||||
gosec -no-fail -fmt sarif -out gosec-results.sarif ./... || true
|
|
||||||
|
|
||||||
- name: Upload gosec SARIF
|
- name: Upload gosec SARIF
|
||||||
if: always() && hashFiles('gosec-results.sarif') != ''
|
if: always() && hashFiles('gosec-results.sarif') != ''
|
||||||
@@ -69,6 +100,47 @@ jobs:
|
|||||||
category: gosec
|
category: gosec
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
||||||
|
codeql:
|
||||||
|
name: CodeQL Analysis
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: ${{ inputs.go-version }}
|
||||||
|
cache: true
|
||||||
|
|
||||||
|
- name: Initialize CodeQL
|
||||||
|
uses: github/codeql-action/init@v3
|
||||||
|
with:
|
||||||
|
languages: go
|
||||||
|
|
||||||
|
- name: Autobuild
|
||||||
|
uses: github/codeql-action/autobuild@v3
|
||||||
|
|
||||||
|
- name: Perform CodeQL Analysis
|
||||||
|
uses: github/codeql-action/analyze@v3
|
||||||
|
|
||||||
|
test:
|
||||||
|
name: Tests & Coverage
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
coverage: ${{ steps.coverage.outputs.coverage }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Setup Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: ${{ inputs.go-version }}
|
||||||
|
cache: true
|
||||||
|
|
||||||
- name: Run tests with coverage
|
- name: Run tests with coverage
|
||||||
run: |
|
run: |
|
||||||
go test -race -coverprofile=coverage.out -covermode=atomic ./...
|
go test -race -coverprofile=coverage.out -covermode=atomic ./...
|
||||||
@@ -81,12 +153,18 @@ jobs:
|
|||||||
echo "coverage=$COVERAGE" >> $GITHUB_OUTPUT
|
echo "coverage=$COVERAGE" >> $GITHUB_OUTPUT
|
||||||
echo "Total Coverage: $COVERAGE%"
|
echo "Total Coverage: $COVERAGE%"
|
||||||
|
|
||||||
|
coverage-report:
|
||||||
|
name: Coverage Report
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: test
|
||||||
|
if: always() && needs.test.result == 'success'
|
||||||
|
steps:
|
||||||
- name: Comment coverage on PR
|
- name: Comment coverage on PR
|
||||||
if: github.event_name == 'pull_request'
|
if: github.event_name == 'pull_request'
|
||||||
uses: actions/github-script@v7
|
uses: actions/github-script@v7
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
const coverage = '${{ steps.coverage.outputs.coverage }}';
|
const coverage = '${{ needs.test.outputs.coverage }}';
|
||||||
const threshold = ${{ inputs.coverage-threshold }};
|
const threshold = ${{ inputs.coverage-threshold }};
|
||||||
const coverageNum = parseFloat(coverage);
|
const coverageNum = parseFloat(coverage);
|
||||||
const hasThreshold = threshold > 0;
|
const hasThreshold = threshold > 0;
|
||||||
@@ -129,7 +207,7 @@ jobs:
|
|||||||
- name: Check coverage threshold
|
- name: Check coverage threshold
|
||||||
if: inputs.coverage-threshold > 0
|
if: inputs.coverage-threshold > 0
|
||||||
run: |
|
run: |
|
||||||
COVERAGE=${{ steps.coverage.outputs.coverage }}
|
COVERAGE=${{ needs.test.outputs.coverage }}
|
||||||
THRESHOLD=${{ inputs.coverage-threshold }}
|
THRESHOLD=${{ inputs.coverage-threshold }}
|
||||||
echo "Coverage: $COVERAGE%"
|
echo "Coverage: $COVERAGE%"
|
||||||
echo "Threshold: $THRESHOLD%"
|
echo "Threshold: $THRESHOLD%"
|
||||||
@@ -138,27 +216,3 @@ jobs:
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "✅ Coverage $COVERAGE% meets threshold $THRESHOLD%"
|
echo "✅ Coverage $COVERAGE% meets threshold $THRESHOLD%"
|
||||||
|
|
||||||
codeql:
|
|
||||||
name: CodeQL Analysis
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Setup Go
|
|
||||||
uses: actions/setup-go@v5
|
|
||||||
with:
|
|
||||||
go-version: ${{ inputs.go-version }}
|
|
||||||
cache: true
|
|
||||||
|
|
||||||
- name: Initialize CodeQL
|
|
||||||
uses: github/codeql-action/init@v3
|
|
||||||
with:
|
|
||||||
languages: go
|
|
||||||
|
|
||||||
- name: Autobuild
|
|
||||||
uses: github/codeql-action/autobuild@v3
|
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
|
||||||
uses: github/codeql-action/analyze@v3
|
|
||||||
|
|||||||
Reference in New Issue
Block a user