Skip to content

Commit e31c124

Browse files
authored
Merge branch 'master' into build_docker
2 parents d38fce0 + bdc4f15 commit e31c124

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+533
-241
lines changed

.codeclimate.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ checks:
66
plugins:
77
gofmt:
88
enabled: true
9-
golint:
10-
enabled: true
119
govet:
1210
enabled: true
1311

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,14 @@ updates:
1313
- "aelsabbahy"
1414
open-pull-requests-limit: 0
1515

16+
- package-ecosystem: "github-actions"
17+
directory: "/"
18+
schedule:
19+
interval: "weekly"
20+
day: "saturday"
21+
22+
- package-ecosystem: "pip"
23+
directory: "/docs"
24+
schedule:
25+
interval: "weekly"
26+
day: "saturday"

.github/workflows/docker-goss.yaml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Docker image for Goss
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
tags:
8+
- "v*"
9+
workflow_dispatch:
10+
11+
env:
12+
PLATFORMS: "linux/amd64,linux/arm64"
13+
14+
jobs:
15+
goss:
16+
name: Build and push Docker image
17+
runs-on: ubuntu-latest
18+
permissions:
19+
packages: write
20+
contents: read
21+
security-events: write # To upload Trivy sarif files
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
27+
- name: Set up QEMU
28+
uses: docker/setup-qemu-action@v3
29+
30+
- name: Set up Docker Buildx
31+
uses: docker/setup-buildx-action@v3
32+
33+
- name: Login to GHCR
34+
uses: docker/login-action@v3
35+
with:
36+
registry: ghcr.io
37+
username: ${{ github.repository_owner }}
38+
password: ${{ secrets.GITHUB_TOKEN }}
39+
40+
- name: Extract metadata (tags, labels) for Docker
41+
id: meta
42+
uses: docker/metadata-action@v5
43+
with:
44+
images: |
45+
ghcr.io/${{ github.repository_owner }}/goss
46+
47+
- name: Get latest git tag
48+
uses: actions-ecosystem/action-get-latest-tag@v1
49+
id: get-latest-tag
50+
51+
- name: Set short git commit SHA
52+
run: |
53+
calculatedSha=$(git rev-parse --short ${{ github.sha }})
54+
echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV
55+
56+
- name: Get the current version of Go from project.
57+
run: echo "GO_VERSION_FROM_PROJECT=$(go mod edit -json | jq -r .Go)" >> $GITHUB_ENV
58+
59+
- name: Build master goss image
60+
if: github.ref_name == 'master'
61+
uses: docker/build-push-action@v5
62+
with:
63+
build-args: |
64+
GO_VERSION=${{ env.GO_VERSION_FROM_PROJECT }}
65+
GOSS_VERSION=${{ steps.get-latest-tag.outputs.tag }}-${{ github.ref_name }}+${{ env.COMMIT_SHORT_SHA }}
66+
context: .
67+
push: true
68+
tags: |
69+
ghcr.io/${{ github.repository_owner }}/goss:master
70+
labels: ${{ steps.meta.outputs.labels }}
71+
platforms: ${{ env.PLATFORMS }}
72+
73+
- name: Build release goss image
74+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
75+
uses: docker/build-push-action@v5
76+
with:
77+
build-args: |
78+
GO_VERSION=${{ env.GO_VERSION_FROM_PROJECT }}
79+
GOSS_VERSION=${{ github.ref_name }}
80+
context: .
81+
push: true
82+
tags: |
83+
ghcr.io/${{ github.repository_owner }}/goss:latest
84+
ghcr.io/${{ github.repository_owner }}/goss:${{ github.ref_name }}
85+
labels: ${{ steps.meta.outputs.labels }}
86+
platforms: ${{ env.PLATFORMS }}
87+
88+
- name: Run Trivy vulnerability scanner
89+
uses: aquasecurity/trivy-action@master
90+
with:
91+
image-ref: ghcr.io/${{ github.repository_owner }}/goss:master
92+
format: "sarif"
93+
output: "trivy-results.sarif"
94+
95+
- name: Upload Trivy scan results to GitHub Security tab
96+
uses: github/codeql-action/upload-sarif@v3
97+
with:
98+
sarif_file: "trivy-results.sarif"

.github/workflows/docs.yaml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
pull_request:
88
paths:
99
- mkdocs.yml
10-
- docs/
10+
- docs/**
1111
- README.md
1212
- LICENSE
1313
- extras/**/README.md
@@ -20,28 +20,31 @@ jobs:
2020
runs-on: ubuntu-latest
2121
steps:
2222
- uses: actions/checkout@v4
23-
- uses: DavidAnson/markdownlint-cli2-action@v13
23+
- uses: DavidAnson/markdownlint-cli2-action@v16
2424
with:
2525
globs: |
2626
docs/**/*.md
27+
README.md
28+
extras/**/README.md
29+
.github/CONTRIBUTING.md
2730
2831
build:
2932
runs-on: ubuntu-latest
3033
steps:
3134
- name: Checkout
3235
uses: actions/checkout@v4
33-
- uses: actions/setup-python@v4
36+
- uses: actions/setup-python@v5
3437
with:
35-
python-version: "3.11"
38+
python-version: "3.12"
3639
cache: 'pip'
3740
- name: Install dependencies
3841
run: |
3942
pip install --upgrade pip
40-
pip install --requirement docs/requirements.pip
43+
pip install --requirement docs/requirements.txt
4144
- name: Build documentation
4245
run: mkdocs build
4346
# To remove if not using github pages
4447
- name: Upload artifact
45-
uses: actions/upload-pages-artifact@v2
48+
uses: actions/upload-pages-artifact@v3
4649
with:
4750
path: site
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Golang ci
2+
on:
3+
# don't build any branch other than master (and prs) when git pushed
4+
pull_request: {}
5+
push:
6+
branches:
7+
- master
8+
- "/^v\\d+\\.\\d+(\\.\\d+)?(-\\S*)?$/"
9+
10+
permissions:
11+
contents: read
12+
pull-requests: read
13+
14+
jobs:
15+
golangci:
16+
name: lint
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
- uses: actions/setup-go@v5
21+
with:
22+
go-version-file: go.mod
23+
- name: golangci-lint
24+
uses: golangci/golangci-lint-action@v6
25+
with:
26+
version: v1.59

.github/workflows/preview-docs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
- opened
66
paths:
77
- mkdocs.yml
8-
- docs/
8+
- docs/**
99
- README.md
1010
- LICENSE
1111
- extras/**/README.md

.golangci.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
linters:
2+
# Disable all linters.
3+
# Default: false
4+
disable-all: true
5+
# Enable specific linter
6+
# https://golangci-lint.run/usage/linters/#enabled-by-default
7+
enable:
8+
# default linter
9+
# - errcheck # there are to many failures at the moment
10+
- gosimple
11+
- govet
12+
- ineffassign
13+
- staticcheck
14+
- unused
15+
# custom linter
16+
- gofmt

.readthedocs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ mkdocs:
1616
# Optionally declare the Python requirements required to build your docs
1717
python:
1818
install:
19-
- requirements: docs/requirements.pip
19+
- requirements: docs/requirements.txt

Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
ARG GO_VERSION=1.21
2+
3+
FROM docker.io/golang:${GO_VERSION}-alpine AS base
4+
5+
ARG GOSS_VERSION=v0.0.0
6+
WORKDIR /build
7+
8+
RUN --mount=target=. \
9+
CGO_ENABLED=0 go build \
10+
-ldflags "-X github.com/goss-org/goss/util.Version=${GOSS_VERSION} -s -w" \
11+
-o "/release/goss" \
12+
./cmd/goss
13+
14+
FROM alpine:3.19
15+
16+
COPY --from=base /release/* /usr/bin/
17+
18+
RUN mkdir /goss
19+
VOLUME /goss

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ htmlcov:
3535
go test -v -coverpkg=./... -coverprofile=c.out ./...
3636
go tool cover -html ./c.out
3737

38-
3938
lint:
4039
$(info INFO: Starting build $@)
41-
golint $(pkgs) || true
40+
go install github.com/golangci/golangci-lint/cmd/[email protected]
41+
golangci-lint run --timeout 5m $(pkgs) || true
4242

4343
vet:
4444
$(info INFO: Starting build $@)
@@ -140,10 +140,10 @@ $(PYTHON):
140140
$(info Creating virtualenv in $(VENV))
141141
@python -m venv $(VENV)
142142

143-
$(DOCS_DEPS): $(PYTHON) docs/requirements.pip
143+
$(DOCS_DEPS): $(PYTHON) docs/requirements.txt
144144
$(info Installing dependencies)
145145
@pip install --upgrade pip
146-
@pip install --requirement docs/requirements.pip
146+
@pip install --requirement docs/requirements.txt
147147
@touch $(DOCS_DEPS)
148148

149149
docs/setup: $(DOCS_DEPS)

0 commit comments

Comments
 (0)