Skip to content

Commit

Permalink
Merge pull request #108 from codacy/fix-download-staticcheck
Browse files Browse the repository at this point in the history
fix installation staticcheck using official binary
  • Loading branch information
DMarinhoCodacy authored Mar 17, 2023
2 parents 9acc82f + 7ccdf09 commit db33ad5
Showing 1 changed file with 7 additions and 8 deletions.
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

0 comments on commit db33ad5

Please sign in to comment.