format #12
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: build and test | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Checkout the code from your repository | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
# Step 2: Set up Go on the runner | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: "1.22.2" # Specify the Go version (adjust as needed) | |
# Step 3: Cache Go modules to improve build time | |
- name: Cache Go modules | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cache/go-build | |
/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
# Step 4: Install dependencies (Go modules) | |
- name: Install dependencies | |
run: go mod tidy | |
# Step 5: Cache node modules | |
- name: Cache node modules | |
uses: actions/cache@v3 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
# Step 6: Build the workflow | |
- name: Build the CI workflow | |
run: go build -o build | |
- name: Run Go workflow script | |
run: ./build |