Skip to content

Commit e862e82

Browse files
added building, linting workflows.
Fixed all linter warnings
1 parent 2b34e26 commit e862e82

9 files changed

Lines changed: 384 additions & 56 deletions

File tree

.github/workflows/build.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request: {}
8+
9+
permissions: {}
10+
11+
jobs:
12+
build:
13+
name: build
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
20+
with:
21+
persist-credentials: false
22+
- name: Install Go
23+
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
24+
with:
25+
go-version-file: go.mod
26+
- name: Build
27+
run: |
28+
make build
29+
30+
test:
31+
name: Test
32+
runs-on: ubuntu-latest
33+
permissions:
34+
contents: read
35+
steps:
36+
- name: Checkout repository
37+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
38+
with:
39+
persist-credentials: false
40+
- name: Install Go
41+
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
42+
with:
43+
go-version-file: go.mod
44+
- name: Test
45+
run: |
46+
make test

.github/workflows/docker.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Build and push Docker image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions: {}
9+
10+
jobs:
11+
build-and-push:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
id-token: write
16+
attestations: write
17+
packages: write
18+
env:
19+
REGISTRY: ghcr.io
20+
IMAGE_NAME: ${{ github.repository }}
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
25+
with:
26+
persist-credentials: false
27+
- name: Login to GitHub Container Registry
28+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
29+
with:
30+
registry: ${{ env.REGISTRY }}
31+
username: ${{ github.actor }}
32+
password: ${{ secrets.GITHUB_TOKEN }}
33+
- name: Build and push image
34+
id: push
35+
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
36+
with:
37+
context: .
38+
push: true
39+
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:dev
40+
- name: Attest
41+
uses: actions/attest-build-provenance@977bb373ede98d70efdf65b84cb5f73e068dcc2a # v 3.0.0
42+
id: attest
43+
with:
44+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
45+
subject-digest: ${{ steps.push.outputs.digest }}
46+
push-to-registry: true
47+
- name: Build and push unsigned image
48+
id: push-unsigned
49+
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
50+
with:
51+
context: .
52+
file: Dockerfile.unsigned
53+
push: true
54+
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:unsigned

.github/workflows/lint.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: golangci-lint
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request: {}
8+
9+
permissions: {}
10+
11+
jobs:
12+
golangci-lint:
13+
name: lint
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
steps:
18+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
19+
with:
20+
persist-credentials: false
21+
- name: Install Go
22+
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
23+
with:
24+
go-version-file: go.mod
25+
- name: golangci-lint
26+
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0

.github/workflows/release.yaml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
release:
13+
name: Build and Release OCI Image
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
packages: write
18+
id-token: write
19+
attestations: write
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
23+
with:
24+
persist-credentials: false
25+
26+
- name: Extract version from tag
27+
id: version
28+
run: |
29+
# Extract the tag name (e.g., v1.0.0)
30+
TAG=${GITHUB_REF#refs/tags/}
31+
echo "tag=${TAG}" >> $GITHUB_OUTPUT
32+
33+
- name: Set up Docker Buildx
34+
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
35+
36+
- name: Log in to GitHub Container Registry
37+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
38+
with:
39+
registry: ghcr.io
40+
username: ${{ github.actor }}
41+
password: ${{ secrets.GITHUB_TOKEN }}
42+
43+
- name: Build and push Docker image
44+
id: push
45+
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
46+
with:
47+
context: .
48+
file: ./Dockerfile
49+
push: true
50+
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.tag }}
51+
platforms: linux/amd64,linux/arm64
52+
53+
- name: Attest build provenance
54+
uses: actions/attest-build-provenance@977bb373ede98d70efdf65b84cb5f73e068dcc2a # v3.0.0
55+
with:
56+
subject-name: ghcr.io/github/artifact-attestations-opa-provider
57+
subject-digest: ${{ steps.push.outputs.digest }}
58+
push-to-registry: true

.golangci.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
version: "2"
2+
linters:
3+
default: none
4+
enable:
5+
- asasalint
6+
- asciicheck
7+
- bidichk
8+
- bodyclose
9+
- contextcheck
10+
- dupword
11+
- durationcheck
12+
- errcheck
13+
- errchkjson
14+
- errorlint
15+
- exhaustive
16+
- gocheckcompilerdirectives
17+
- gochecksumtype
18+
- gocritic
19+
- godot
20+
- godox
21+
- gosec
22+
- gosmopolitan
23+
- govet
24+
- ineffassign
25+
- loggercheck
26+
- makezero
27+
- misspell
28+
- musttag
29+
- nilerr
30+
- nilnesserr
31+
- noctx
32+
- protogetter
33+
- reassign
34+
- recvcheck
35+
- revive
36+
- rowserrcheck
37+
- spancheck
38+
- sqlclosecheck
39+
- staticcheck
40+
- testifylint
41+
- unparam
42+
- unused
43+
- zerologlint
44+
settings:
45+
revive:
46+
enable-all-rules: true
47+
rules:
48+
- name: add-constant
49+
disabled: true
50+
- name: argument-limit
51+
arguments:
52+
- 6
53+
severity: warning
54+
disabled: false
55+
- name: confusing-naming
56+
disabled: true
57+
- name: confusing-results
58+
disabled: true
59+
- name: cyclomatic
60+
arguments:
61+
- 7
62+
disabled: true
63+
- name: file-header
64+
disabled: true
65+
- name: line-length-limit
66+
arguments:
67+
- 80
68+
severity: warning
69+
disabled: true
70+
- name: function-length
71+
disabled: true
72+
- name: cognitive-complexity
73+
disabled: true
74+
- name: max-public-structs
75+
disabled: true
76+
- name: banned-characters
77+
disabled: true
78+
- name: function-result-limit
79+
arguments:
80+
- 3
81+
severity: warning
82+
disabled: false
83+
- name: flag-parameter
84+
disabled: true
85+
- name: package-comments
86+
disabled: true
87+
wsl:
88+
allow-cuddle-declarations: true
89+
force-err-cuddling: true
90+
force-short-decl-cuddling: true
91+
exclusions:
92+
generated: lax
93+
presets:
94+
- common-false-positives
95+
- legacy
96+
- std-error-handling
97+
paths:
98+
- third_party$
99+
- builtin$
100+
- examples$
101+
formatters:
102+
enable:
103+
- gofmt
104+
exclusions:
105+
generated: lax
106+
paths:
107+
- third_party$
108+
- builtin$
109+
- examples$

0 commit comments

Comments
 (0)