Skip to content

Go

Go #190

Workflow file for this run

# Workflow used as Continous Integration every time we have a PR.
name: Go
on:
# Only build when pushed to main
push:
branches:
- main
paths:
- '**.go'
- 'go.mod'
- 'go.sum'
# Build all pull requests
pull_request:
branches:
- main
paths:
- '**.go'
- 'go.mod'
- 'go.sum'
schedule:
- cron: '36 7 * * 0'
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
fetch-depth: 1
- run: git config --global url.https://${{ secrets.GH_GO_MOD_TOKEN }}@github.com/.insteadOf https://github.com/
- name: Set up Go
uses: actions/setup-go@v5
with:
cache: false
go-version-file: 'go.mod'
- name: Lint with golangci-lint
uses: golangci/golangci-lint-action@v4
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- run: git config --global url.https://${{ secrets.GH_GO_MOD_TOKEN }}@github.com/.insteadOf https://github.com/
- name: Build
run: go build ./...
- name: Run Unit Tests
run: go test ./... -json > test.json
- name: Annotate Tests
uses: guyarb/[email protected]
with:
test-results: test.json
analyze:
name: Analyze
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners
# Consider using larger runners for possible analysis time improvements.
runs-on: ubuntu-latest
timeout-minutes: 360
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: 'go'
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Build
run: go build -o saferplace ./cmd/saferplace
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v3
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:go"