Skip to content

Commit

Permalink
Add go format checks via github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
danielle-tfh committed Jul 4, 2024
1 parent e645560 commit 35cec25
Showing 1 changed file with 41 additions and 3 deletions.
44 changes: 41 additions & 3 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit 35cec25

Please sign in to comment.