Skip to content
Snippets Groups Projects
Unverified Commit c9f5002d authored by Will McCutchen's avatar Will McCutchen Committed by GitHub
Browse files

Build & CI updates (#116)

A few small tweaks:
- Simplify makefile
- Cancel in-progress CI jobs when new commits are pushed to a non-main
branch
- Drop manual codeql config now that GitHub supports automagical
configuration
parent cbbc2968
No related branches found
No related tags found
No related merge requests found
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches: [ "main" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
schedule:
- cron: '28 8 * * 6'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'go' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
steps:
- name: Checkout repository
uses: actions/checkout@v3
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
# ℹ️ 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@v2
with:
category: "/language:${{matrix.language}}"
......@@ -6,6 +6,11 @@ on:
pull_request:
branches: [main] # pull requests AGAINST main
# cancel CI runs when a new commit is pushed to any branch except main
concurrency:
group: "lint-${{ github.ref }}"
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
golangci:
name: Lint
......@@ -17,4 +22,4 @@ jobs:
go-version: '1.20'
- uses: golangci/golangci-lint-action@v3.4.0
with:
version: v1.51.1
version: v1.52.2
......@@ -11,6 +11,11 @@ on:
pull_request:
branches: [main]
# cancel CI runs when a new commit is pushed to any branch except main
concurrency:
group: "test-${{ github.ref }}"
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
jobs:
test:
name: Test
......
......@@ -11,10 +11,10 @@ COVERAGE_PATH ?= coverage.txt
COVERAGE_ARGS ?= -covermode=atomic -coverprofile=$(COVERAGE_PATH)
TEST_ARGS ?= -race
# Tool dependencies
TOOL_BIN_DIR ?= $(shell go env GOPATH)/bin
TOOL_GOLINT := $(TOOL_BIN_DIR)/golint
TOOL_STATICCHECK := $(TOOL_BIN_DIR)/staticcheck
# 3rd party tools
GOLINT := go run golang.org/x/lint/golint@latest
REFLEX := go run github.com/cespare/reflex@v0.3.1
STATICCHECK := go run honnef.co/go/tools/cmd/staticcheck@2023.1.3
# =============================================================================
......@@ -58,11 +58,11 @@ testcover: testci
go tool cover -html=$(COVERAGE_PATH)
.PHONY: testcover
lint: $(TOOL_GOLINT) $(TOOL_STATICCHECK)
lint:
test -z "$$(gofmt -d -s -e .)" || (echo "Error: gofmt failed"; gofmt -d -s -e . ; exit 1)
go vet ./...
$(TOOL_GOLINT) -set_exit_status ./...
$(TOOL_STATICCHECK) ./...
$(GOLINT) -set_exit_status ./...
$(STATICCHECK) ./...
.PHONY: lint
......@@ -73,8 +73,8 @@ run: build
$(DIST_PATH)/go-httpbin
.PHONY: run
watch: $(TOOL_REFLEX)
reflex -s -r '\.(go|html)$$' make run
watch:
$(REFLEX) -s -r '\.(go|html)$$' make run
.PHONY: watch
......@@ -91,18 +91,3 @@ imagepush:
docker buildx build --push --platform linux/amd64,linux/arm64 -t $(DOCKER_TAG) .
docker buildx rm httpbin
.PHONY: imagepush
# =============================================================================
# dependencies
#
# Deps are installed outside of working dir to avoid polluting go modules
# =============================================================================
$(TOOL_GOLINT):
go install golang.org/x/lint/golint@latest
$(TOOL_REFLEX):
go install github.com/cespare/reflex@0.3.1
$(TOOL_STATICCHECK):
go install honnef.co/go/tools/cmd/staticcheck@v0.3.0
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment