-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add actions workflows and unit tests (#1)
Signed-off-by: Matt Moore <mattmoor@chainguard.dev>
- Loading branch information
Showing
6 changed files
with
423 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Copyright 2022 Chainguard, Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
name: Action Lint | ||
|
||
on: | ||
pull_request: | ||
branches: [ 'main', 'release-*' ] | ||
|
||
jobs: | ||
|
||
action-lint: | ||
name: Action lint | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
|
||
- name: Find yamls | ||
id: get_yamls | ||
run: | | ||
yamls="$(find .github/workflows -name "*.y*ml" | grep -v dependabot. | xargs echo)" | ||
echo "files=${yamls}" >> "$GITHUB_OUTPUT" | ||
- name: Action lint | ||
uses: reviewdog/action-actionlint@9ccda195fd3a290c8596db7f1958c897deaa8c76 # v1.40.0 | ||
with: | ||
actionlint_flags: ${{ steps.get_yamls.outputs.files }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright 2022 Chainguard, Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
name: Do Not Submit | ||
|
||
on: | ||
pull_request: | ||
branches: [ 'main', 'release-*' ] | ||
|
||
jobs: | ||
|
||
donotsubmit: | ||
name: Do Not Submit | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
|
||
- name: Do Not Submit | ||
uses: chainguard-dev/actions/donotsubmit@main |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Copyright 2022 Chainguard, Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
name: Test | ||
|
||
on: | ||
pull_request: | ||
branches: [ 'main', 'release-*' ] | ||
push: | ||
branches: [ 'main', 'release-*' ] | ||
|
||
jobs: | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code onto GOPATH | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
|
||
# https://github.com/mvdan/github-actions-golang#how-do-i-set-up-caching-between-builds | ||
- uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2 | ||
with: | ||
# In order: | ||
# * Module download cache | ||
# * Build cache (Linux) | ||
path: | | ||
~/go/pkg/mod | ||
~/.cache/go-build | ||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go- | ||
- name: Set up Go | ||
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 | ||
with: | ||
go-version-file: './go.mod' | ||
check-latest: true | ||
|
||
- run: | | ||
# Exclude running unit tests against third_party repos. | ||
go test -race ./... |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# Copyright 2022 Chainguard, Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
name: Code Style | ||
|
||
on: | ||
pull_request: | ||
branches: [ 'main', 'release-*' ] | ||
push: | ||
branches: [ 'main', 'release-*' ] | ||
|
||
jobs: | ||
|
||
gofmt: | ||
name: check gofmt | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 | ||
with: | ||
go-version-file: './go.mod' | ||
check-latest: true | ||
|
||
- uses: chainguard-dev/actions/gofmt@main | ||
with: | ||
args: -s | ||
|
||
goimports: | ||
name: check goimports | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 | ||
with: | ||
go-version-file: './go.mod' | ||
check-latest: true | ||
|
||
- uses: chainguard-dev/actions/goimports@main | ||
|
||
golangci-lint: | ||
name: golangci-lint | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 | ||
with: | ||
go-version-file: './go.mod' | ||
check-latest: true | ||
cache: true | ||
|
||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0 | ||
with: | ||
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. | ||
version: v1.54 | ||
args: --timeout=5m | ||
|
||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 | ||
with: | ||
go-version-file: './go.mod' | ||
check-latest: true | ||
|
||
- uses: chainguard-dev/actions/trailing-space@main | ||
if: ${{ always() }} | ||
|
||
- uses: chainguard-dev/actions/eof-newline@main | ||
if: ${{ always() }} | ||
|
||
- uses: reviewdog/action-tflint@master | ||
if: ${{ always() }} | ||
with: | ||
github_token: ${{ secrets.github_token }} | ||
fail_on_error: true | ||
|
||
- uses: reviewdog/action-misspell@06d6a480724fa783c220081bbc22336a78dbbe82 # v1.15.0 | ||
if: ${{ always() }} | ||
with: | ||
github_token: ${{ secrets.github_token }} | ||
fail_on_error: true | ||
locale: "US" | ||
exclude: | | ||
**/go.sum | ||
**/third_party/** | ||
./*.yml | ||
- uses: get-woke/woke-action-reviewdog@d71fd0115146a01c3181439ce714e21a69d75e31 # v0 | ||
if: ${{ always() }} | ||
with: | ||
github-token: ${{ secrets.github_token }} | ||
reporter: github-pr-check | ||
level: error | ||
fail-on-error: true |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Validate, Lint and Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
lint-and-validate: | ||
name: "Terraform fmt and validate" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
- uses: hashicorp/setup-terraform@a1502cd9e758c50496cc9ac5308c4843bcd56d36 # v3.0.0 | ||
|
||
- run: terraform fmt -check | ||
|
||
- run: | | ||
terraform init | ||
terraform validate |
Oops, something went wrong.