Merge pull request #17 from WillyTonkas/not-feature/back/ci-cd #13
Workflow file for this run
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
name: CI Workflow | |
on: | |
pull_request: | |
branches: ["main", "dev"] | |
push: | |
branches-ignore: ["main"] | |
jobs: | |
lint-and-test: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.23' | |
- name: Cache Go modules | |
uses: actions/cache@v3 | |
with: | |
path: ~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- name: Check formatting with gofmt | |
run: | | |
echo "Checking code formatting with gofmt..." | |
unformatted=$(gofmt -l .) | |
if [ -n "$unformatted" ]; then | |
echo "The following files are not formatted:" | |
echo "$unformatted" | |
exit 1 | |
fi | |
- name: Run golint | |
run: golint ./... || exit 1 | |
- name: Run tests | |
run: go test ./... -v |