Skip to content

Commit aff00f3

Browse files
authored
🔨 chore: Updates/Modernizes codeql, lint & test workflows
1 parent 660e4c7 commit aff00f3

File tree

6 files changed

+855
-1108
lines changed

6 files changed

+855
-1108
lines changed

.github/workflows/codeql.yml

Lines changed: 56 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,74 +9,101 @@
99
# the `language` matrix defined below to confirm you have the correct set of
1010
# supported CodeQL languages.
1111
#
12-
name: "CodeQL"
12+
name: "CodeQL Advanced"
1313

1414
on:
1515
push:
1616
branches: ["main"]
1717
pull_request:
18-
# The branches below must be a subset of the branches above
1918
branches: ["main"]
2019
schedule:
21-
- cron: "0 0 * * 1"
22-
23-
permissions:
24-
contents: read
20+
- cron: "19 3 * * 1"
2521

2622
jobs:
2723
analyze:
28-
name: Analyze
29-
runs-on: ubuntu-latest
24+
name: Analyze (${{ matrix.language }})
25+
# Runner size impacts CodeQL analysis time. To learn more, please see:
26+
# - https://gh.io/recommended-hardware-resources-for-running-codeql
27+
# - https://gh.io/supported-runners-and-hardware-resources
28+
# - https://gh.io/using-larger-runners (GitHub.com only)
29+
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
30+
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
3031
permissions:
32+
# required for all workflows
33+
security-events: write
34+
35+
# required to fetch internal or private CodeQL packs
36+
packages: read
37+
38+
# only required for workflows in private repositories
3139
actions: read
3240
contents: read
33-
security-events: write
3441

3542
strategy:
3643
fail-fast: false
3744
matrix:
38-
language: ["go"]
39-
# CodeQL supports [ $supported-codeql-languages ]
40-
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
41-
45+
include:
46+
- language: actions
47+
build-mode: none
48+
- language: go
49+
build-mode: autobuild
50+
# CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
51+
# Use `c-cpp` to analyze code written in C, C++ or both
52+
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
53+
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
54+
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
55+
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
56+
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
57+
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
4258
steps:
4359
- name: Harden Runner
44-
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
60+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
4561
with:
4662
egress-policy: audit
4763

4864
- name: Checkout repository
4965
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
5066

51-
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
67+
# Add any setup steps before running the `github/codeql-action/init` action.
68+
# This includes steps like installing compilers or runtimes (`actions/setup-node`
69+
# or others). This is typically only required for manual builds.
70+
# - name: Setup runtime (example)
71+
# uses: actions/setup-example@v1
72+
- if: matrix.language == 'go'
73+
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
5274
with:
53-
go-version: "1.21.4"
75+
go-version-file: test/go.mod
5476

5577
# Initializes the CodeQL tools for scanning.
5678
- name: Initialize CodeQL
57-
uses: github/codeql-action/init@f09c1c0a94de965c15400f5634aa42fac8fb8f88 # v3.27.5
79+
uses: github/codeql-action/init@28deaeda66b76a05916b6923827895f2b14ab387 # v3.28.16
5880
with:
5981
languages: ${{ matrix.language }}
82+
build-mode: ${{ matrix.build-mode }}
6083
# If you wish to specify custom queries, you can do so here or in a config file.
6184
# By default, queries listed here will override any specified in a config file.
6285
# Prefix the list here with "+" to use these queries and those in the config file.
6386

64-
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
65-
# If this step fails, then you should remove it and run the build manually (see below)
66-
- name: Autobuild
67-
uses: github/codeql-action/autobuild@f09c1c0a94de965c15400f5634aa42fac8fb8f88 # v3.27.5
87+
# For more 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
88+
# queries: security-extended,security-and-quality
6889

90+
# If the analyze step fails for one of the languages you are analyzing with
91+
# "We were unable to automatically build your code", modify the matrix above
92+
# to set the build mode to "manual" for that language. Then modify this step
93+
# to build your code.
6994
# ℹ️ Command-line programs to run using the OS shell.
7095
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
71-
72-
# If the Autobuild fails above, remove it and uncomment the following three lines.
73-
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
74-
75-
# - run: |
76-
# echo "Run, Build Application using script"
77-
# ./location_of_script_within_repo/buildscript.sh
96+
- if: matrix.build-mode == 'manual'
97+
shell: bash
98+
run: |
99+
echo 'If you are using a "manual" build mode for one or more of the' \
100+
'languages you are analyzing, replace this with the commands to build' \
101+
'your code, for example:'
102+
echo ' make bootstrap'
103+
echo ' make release'
104+
exit 1
78105
79106
- name: Perform CodeQL Analysis
80-
uses: github/codeql-action/analyze@f09c1c0a94de965c15400f5634aa42fac8fb8f88 # v3.27.5
107+
uses: github/codeql-action/analyze@28deaeda66b76a05916b6923827895f2b14ab387 # v3.28.16
81108
with:
82109
category: "/language:${{matrix.language}}"

.github/workflows/lint.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,14 @@ jobs:
6363

6464
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
6565
- name: golangci-lint
66-
uses: reviewdog/action-golangci-lint@7708105983c614f7a2725e2172908b7709d1c3e4 # v2.6.2
66+
uses: reviewdog/action-golangci-lint@f9bba13753278f6a73b27a56a3ffb1bfda90ed71 # v2.8.0
6767
with:
6868
github_token: ${{ github.token }}
6969
reporter: github-pr-review
7070
fail_on_error: "false"
7171
filter_mode: file
7272
workdir: test/
7373
go_version_file: test/go.mod
74-
golangci_lint_flags: --verbose --presets
75-
bugs,comment,complexity,error,format,import,metalinter,module,performance,style,unused
76-
--fast --exclude-use-default --tests --timeout 120s ./...
7774
prettier:
7875
runs-on: ubuntu-latest
7976
permissions:

.github/workflows/test.yml

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,40 @@ jobs:
1313
terratest:
1414
runs-on: ubuntu-latest
1515
steps:
16-
- name: Harden Runner
16+
- name: "Harden Runner"
1717
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
1818
with:
1919
egress-policy: audit
2020

21-
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
21+
- name: "Checkout"
22+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
23+
24+
- name: "Setup Go"
25+
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
2226
with:
23-
go-version: "1.21.4"
27+
go-version-file: test/go.mod
28+
cache: true
29+
30+
- name: "Setup Terraform"
31+
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd #v3.1.2
32+
33+
- name: "Install JUnit Reporter"
34+
working-directory: test
35+
run: go install github.com/jstemmer/go-junit-report/[email protected]
36+
37+
- name: "Run Tests"
38+
working-directory: test
39+
shell: bash
40+
run: go test -timeout 20m -v ./... 2>&1 | tee results.out
41+
42+
- name: "Convert Test Results"
43+
working-directory: test
44+
shell: bash
45+
if: hashFiles('test/results.out') != ''
46+
run: go-junit-report -set-exit-code < results.out > results.xml
2447

25-
- name: terratest
26-
uses: cloudposse/github-action-terratest@dee3c6c2a6f988c4405965ed69972925a5c3a0b2 # main
48+
- name: "Upload Test Results"
49+
uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # v2.4
50+
if: hashFiles('test/results.xml') != ''
2751
with:
28-
sourceDir: test
52+
paths: test/results.xml

0 commit comments

Comments
 (0)