Skip to content

Commit

Permalink
Add deadcode analysis CI check
Browse files Browse the repository at this point in the history
Fail the build if any dead code is detected.
  • Loading branch information
andrew-farries committed Jan 25, 2024
1 parent 908485f commit f213dd8
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,30 @@ jobs:
exit 1
fi
dead-code-check:
name: dead code check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'

- name: Install deadcode tool
run: |
go install golang.org/x/tools/cmd/deadcode@latest
- name: Run deadcode analysis
run: |
deadcode --test ./... > deadcode-out
if [ ! -s deadcode-out ]; then
echo "Dead code analysis failed!"
echo "Dead code analysis found the following dead code:"
cat deadcode-out
fi
license-check:
name: license check
runs-on: ubuntu-latest
Expand Down Expand Up @@ -124,7 +148,7 @@ jobs:
release:
runs-on: ubuntu-latest
needs: [test, lint, examples, license-check, type-generation]
needs: [test, lint, examples, license-check, type-generation, dead-code-check]
if: startsWith(github.ref, 'refs/tags/')
env:
DOCKER_CLI_EXPERIMENTAL: "enabled"
Expand Down

0 comments on commit f213dd8

Please sign in to comment.