Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix installation staticcheck using official binary #108

Merged
merged 3 commits into from
Mar 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,26 +136,25 @@ runs:
else
echo "Skipping GoSec"
fi

- name: set-up go
uses: actions/setup-go@v3
with:
go-version: 1.20.2
- name: "Run StaticCheck"
shell: bash
run: |
set -eux

if [ "${{ inputs.run-staticcheck }}" == "true" ]; then
cd /tmp
curl -fsSL https://api.github.com/repos/dominikh/go-tools/releases/latest \
| grep -E "browser_download_url.*staticcheck_linux_amd64.tar.gz\"$" \
| cut -d '"' -f 4 \
| xargs -L 1 curl -fsSL -o /tmp/staticcheck_linux_amd64.tar.gz
tar -xvf /tmp/staticcheck_linux_amd64.tar.gz staticcheck/staticcheck
chmod +x ./staticcheck/staticcheck
go install honnef.co/go/tools/cmd/staticcheck@2023.1.2
chmod +x /home/runner/go/bin/staticcheck
CODACY_STATICCHECK_VERSION=$(curl -SL "https://artifacts.codacy.com/bin/codacy-staticcheck/latest" -o-)
curl -fsSL "https://artifacts.codacy.com/bin/codacy-staticcheck/$CODACY_STATICCHECK_VERSION/codacy-staticcheck-$CODACY_STATICCHECK_VERSION" -o /tmp/codacy-staticcheck
chmod +x /tmp/codacy-staticcheck
cd -

find . -type f -name go.mod -exec bash -c 'cd $(dirname $1); cp $1 $1.codacy.bak; PKGS=$(go list ./...); /tmp/staticcheck/staticcheck -f json $PKGS; mv $1.codacy.bak $1' _ {} \; > /tmp/staticcheck-out.json
find . -type f -name go.mod -exec bash -c 'cd $(dirname $1); cp $1 $1.codacy.bak; PKGS=$(go list ./...); /home/runner/go/bin/staticcheck -f json $PKGS; mv $1.codacy.bak $1' _ {} \; > /tmp/staticcheck-out.json
/tmp/codacy-staticcheck < /tmp/staticcheck-out.json > /tmp/codacy-out.json
if [ ${{ inputs.upload }} = true ]; then
curl -XPOST -L -H "$CURL_CODACY_AUTH_AUTHENTICATION" \
Expand Down