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 fc3b2a1
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,31 @@ 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 --json ./... > out.json
if ! echo 'null' | diff - out.json > /dev/null; then
echo "Dead code analysis failed!"
echo "Dead code analysis found the following dead code:"
cat out.json
exit 1
fi
license-check:
name: license check
runs-on: ubuntu-latest
Expand Down Expand Up @@ -124,7 +149,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 fc3b2a1

Please sign in to comment.