-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add go format checks via github actions
- Loading branch information
1 parent
e645560
commit 35cec25
Showing
1 changed file
with
41 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ env: | |
AWS_ENDPOINT: http://localstack:4566 | ||
|
||
jobs: | ||
test: | ||
test-and-format: | ||
runs-on: ubuntu-latest | ||
container: golang:1.21.6-alpine3.19 | ||
services: | ||
|
@@ -18,8 +18,46 @@ jobs: | |
steps: | ||
- name: Check out repository code | ||
uses: actions/checkout@v4 | ||
- run: apk add git gcc musl-dev | ||
- run: go test ./... | ||
- run: git config --global url."https://${{ secrets.GIT_HUB_TOKEN }}:[email protected]/worldcoin/".insteadOf "https://github.com/worldcoin/" | ||
- uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.cache/go-build | ||
~/go/pkg/mod | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- run: godotenv -f env.ci gotestsum --format testname | ||
- name: Run go fmt | ||
run: | | ||
go fmt ./... | ||
- name: Add safe directory for Git | ||
run: | | ||
git config --global --add safe.directory $GITHUB_WORKSPACE | ||
git config --global --get-all safe.directory | ||
- name: Debug Checkout | ||
run: | | ||
echo "Debugging Checkout Step" | ||
ls -al | ||
cat .git/config || echo ".git/config not found" | ||
git status || true | ||
- name: Verify Checkout | ||
run: | | ||
pwd | ||
ls -al | ||
if [ -d .git ]; then echo ".git directory exists"; else echo ".git directory is missing"; fi | ||
git status || true # Ensure we continue even if this fails | ||
- name: Verify Git repository | ||
run: | | ||
pwd | ||
ls -al | ||
git status | ||
git rev-parse --is-inside-work-tree | ||
- name: Verify no changes | ||
run: | | ||
echo "Checking for unformatted code..." | ||
git diff --exit-code || (echo "Unformatted code found. Please run 'go fmt' and commit the changes." && exit 1) | ||
working-directory: ${{ github.workspace }} | ||
snyk-scan: | ||
runs-on: ubuntu-latest | ||
env: | ||
|