Skip to content

Commit a1502df

Browse files
authored
Merge pull request #62 from raffis/next
feat(ci): use golreleaser, clean actions, update to go1.19
2 parents 82cd97a + 7edfe38 commit a1502df

32 files changed

+182
-178
lines changed

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
- package-ecosystem: "gomod"
8+
directory: "/"
9+
schedule:
10+
interval: "weekly"

.github/workflows/nightly.yaml

Lines changed: 0 additions & 36 deletions
This file was deleted.

.github/workflows/e2e.yaml renamed to .github/workflows/pr-build.yaml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
name: e2e
1+
name: pr-build
22

33
on:
44
pull_request:
5-
push:
6-
branches:
7-
- main
8-
- release-v1.0
5+
types:
6+
- opened
7+
- synchronize
8+
- reopened
99

1010
jobs:
1111
build:
@@ -15,20 +15,20 @@ jobs:
1515
runs-on: ubuntu-latest
1616
steps:
1717
- name: Checkout
18-
uses: actions/checkout@v2
18+
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3
1919
- name: Setup Go
20-
uses: actions/setup-go@v2
20+
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f #v3.3.1
2121
with:
22-
go-version: 1.17.x
22+
go-version: 1.18.x
2323
- name: Restore Go cache
24-
uses: actions/cache@v1
24+
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 #v3.0.11
2525
with:
26-
path: /home/runner/work/_temp/_github_home/go/pkg/mod
26+
path: ~/go/pkg/mod
2727
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
2828
restore-keys: |
2929
${{ runner.os }}-go-
3030
- name: Setup Kubernetes
31-
uses: engineerd/[email protected]
31+
uses: engineerd/setup-kind@aa272fe2a7309878ffc2a81c56cfe3ef108ae7d0 #v0.5.0
3232
with:
3333
version: v0.11.1
3434
image: kindest/node:v1.21.1@sha256:69860bda5563ac81e3c0057d654b5253219618a22ec3a346306239bba8cfa1a6
@@ -64,7 +64,7 @@ jobs:
6464
run: make deploy-test IMG=test/mongodb-query-exporter:latest
6565
- name: Setup MongoDB
6666
env:
67-
MONGODB_VER: ${{ '10.29.2' }}
67+
MONGODB_VER: ${{ '13.5.0' }}
6868
run: |
6969
kubectl create ns mongodb
7070
helm repo add bitnami https://charts.bitnami.com/bitnami
@@ -76,17 +76,17 @@ jobs:
7676
--set image.tag=${{matrix.mongodb}}
7777
- name: Run tests
7878
run: |
79+
sleep 5
7980
kubectl -n mongodb-system port-forward deployment/mongodb-query-exporter 9412:9412 &>/dev/null &
8081
sleep 2
8182
curl -v --fail http://localhost:9412/metrics | grep total_mongodb_users
82-
- name: Logs
83-
run: |
84-
kubectl -n mongodb-system logs deploy/mongodb-query-exporter
8583
- name: Debug failure
8684
if: failure()
8785
run: |
88-
kubectl -n kube-system describe pods
86+
kubectl -n mongodb get pods
87+
kubectl -n mongodb-system get pods
8988
kubectl -n mongodb describe pods
9089
kubectl -n mongodb-system describe pods
91-
kubectl -n mongodb-system get all
90+
kubectl -n mongodb get svc
91+
kubectl -n kube-system get pods
9292
kubectl -n mongodb-system logs deploy/mongodb-query-exporter

.github/workflows/chart.yaml renamed to .github/workflows/pr-chart.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,36 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- name: Checkout
10-
uses: actions/checkout@v2
10+
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3
1111
with:
1212
fetch-depth: 0
1313

1414
- name: Set up Helm
15-
uses: azure/setup-helm@v1
15+
uses: azure/setup-helm@f382f75448129b3be48f8121b9857be18d815a82 #v3.4
1616
with:
1717
version: v3.4.0
1818

19-
- uses: actions/setup-python@v2
19+
- uses: actions/setup-python@13ae5bb136fac2878aff31522b9efb785519f984 #v4.3.0
2020
with:
2121
python-version: 3.7
2222

2323
- name: Set up chart-testing
24-
uses: helm/chart-testing-action@v2.1.0
24+
uses: helm/chart-testing-action@afea100a513515fbd68b0e72a7bb0ae34cb62aec #v2.3.1
2525

2626
- name: Run chart-testing (list-changed)
2727
id: list-changed
2828
run: |
29-
changed=$(ct list-changed --chart-dirs chart)
29+
changed=$(ct list-changed --target-branch=master --chart-dirs chart)
3030
if [[ -n "$changed" ]]; then
3131
echo "::set-output name=changed::true"
3232
fi
3333
3434
- name: Run chart-testing (lint)
35-
run: ct lint --chart-dirs chart
35+
run: ct lint --target-branch=master --chart-dirs chart
3636

3737
- name: Create kind cluster
38-
uses: helm/kind-action@v1.2.0
38+
uses: helm/kind-action@9e8295d178de23cbfbd8fa16cf844eec1d773a07 #v1.4.0
3939
if: steps.list-changed.outputs.changed == 'true'
4040

4141
- name: Run chart-testing (install)
42-
run: ct install --chart-dirs chart
42+
run: ct install --target-branch=master --chart-dirs chart

.github/workflows/rebase.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Checkout the latest code
15-
uses: actions/checkout@v2
15+
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3
1616
with:
1717
fetch-depth: 0
1818
- name: Automatic Rebase
19-
uses: cirrus-actions/rebase@1.3.1
19+
uses: cirrus-actions/rebase@6e572f08c244e2f04f9beb85a943eb618218714d #1.7
2020
env:
2121
GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}

.github/workflows/release-chart.yaml

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,28 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Checkout
13-
uses: actions/checkout@v2
13+
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3
1414
with:
1515
fetch-depth: 0
1616

17-
- name: Configure Git
18-
run: |
19-
git config user.name "$GITHUB_ACTOR"
20-
git config user.email "[email protected]"
17+
- name: Install Helm
18+
uses: azure/setup-helm@f382f75448129b3be48f8121b9857be18d815a82 #v3.4
2119

22-
- name: Run chart-releaser
23-
uses: helm/chart-releaser-action@v1.3.0
20+
- name: Install yq
21+
uses: chrisdickinson/setup-yq@3d931309f27270ebbafd53f2daee773a82ea1822 #v1.0.1
2422
with:
25-
charts_dir: ./chart
26-
env:
27-
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
23+
yq-version: v4.24.5
24+
25+
- name: Login to Github Container Registry using helm
26+
run: echo ${{ secrets.GITHUB_TOKEN }} | helm registry login ghcr.io --username ${{ github.actor }} --password-stdin
27+
28+
- name: Package helm charts
29+
run: |
30+
chartVersion=$(helm show chart chart/mongodb-query-exporter | yq e '.version')
31+
appVersion=$(helm show chart chart/mongodb-query-exporter | yq e '.version')
32+
helm package chart/mongodb-query-exporter --version=$chartVersion --app-version=$appVersion -d chart
33+
34+
- name: Publish helm charts to Github Container Registry
35+
run: |
36+
repository=$(echo "${{ github.repository_owner }}" | tr [:upper:] [:lower:])
37+
helm push ${{ github.workspace }}/chart/mongodb-query-exporter-*.tgz oci://ghcr.io/$repository/charts

.github/workflows/release.yaml

Lines changed: 11 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -3,88 +3,37 @@ on:
33
push:
44
tags:
55
- 'v*'
6-
workflow_dispatch:
7-
inputs:
8-
tag:
9-
description: 'image tag prefix'
10-
required: true
116

127
permissions:
138
contents: write # needed to write releases
149
id-token: write # needed for keyless signing
1510
packages: write # needed for ghcr access
1611

17-
env:
18-
APP: ${{ github.event.repository.name }}
19-
2012
jobs:
2113
build:
2214
name: Build
2315
runs-on: ubuntu-latest
2416
steps:
2517
- name: Checkout code
26-
uses: actions/checkout@v2
27-
- uses: actions/[email protected]
28-
with:
29-
go-version: '1.17'
30-
- name: Prepare
31-
id: prep
32-
run: |
33-
VERSION="${{ github.event.inputs.tag }}-${GITHUB_SHA::8}"
34-
if [[ $GITHUB_REF == refs/tags/* ]]; then
35-
VERSION=${GITHUB_REF/refs\/tags\//}
36-
fi
37-
echo ::set-output name=BUILD_DATE::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
38-
echo ::set-output name=VERSION::${VERSION}
39-
- name: Setup QEMU
40-
uses: docker/setup-qemu-action@v1
41-
with:
42-
platforms: all
43-
- name: Setup Docker Buildx
44-
id: buildx
45-
uses: docker/setup-buildx-action@v1
18+
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3
19+
- uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f #v3.3.1
4620
with:
47-
buildkitd-flags: "--debug"
48-
- name: Login to GitHub Container Registry
49-
uses: docker/login-action@v1
21+
go-version: '1.18'
22+
- name: Docker Login
23+
uses: docker/login-action@v2
5024
with:
5125
registry: ghcr.io
5226
username: ${{ github.actor }}
5327
password: ${{ secrets.GITHUB_TOKEN }}
54-
- name: Generate images meta
55-
id: meta
56-
uses: docker/metadata-action@v3
57-
with:
58-
images: |
59-
ghcr.io/raffis/${{ env.APP }}
60-
tags: |
61-
type=raw,value=${{ steps.prep.outputs.VERSION }}
62-
- name: Publish multi-arch container image
63-
uses: docker/build-push-action@v2
64-
with:
65-
push: true
66-
builder: ${{ steps.buildx.outputs.name }}
67-
context: .
68-
file: ./Dockerfile
69-
platforms: linux/amd64,linux/arm/v7,linux/arm64
70-
tags: ${{ steps.meta.outputs.tags }}
71-
labels: ${{ steps.meta.outputs.labels }}
72-
- name: Check images
73-
run: |
74-
docker buildx imagetools inspect ghcr.io/raffis/${{ env.APP }}:${{ steps.prep.outputs.VERSION }}
75-
docker pull ghcr.io/raffis/${{ env.APP }}:${{ steps.prep.outputs.VERSION }}
76-
- name: Generate release manifests
77-
if: startsWith(github.ref, 'refs/tags/v')
78-
run: |
79-
mkdir -p deploy/release
80-
kustomize build ./deploy/exporter > ./deploy/release/${{ env.APP }}.deployment.yaml
81-
echo '[CHANGELOG](https://github.com/raffis/${{ env.APP }}/blob/master/CHANGELOG.md)' > ./deploy/release/notes.md
82-
- uses: anchore/sbom-action/download-syft@v0
28+
- name: Setup Cosign
29+
uses: sigstore/cosign-installer@9becc617647dfa20ae7b1151972e9b3a2c338a2b #v2.8.1
30+
- uses: anchore/sbom-action/download-syft@06e109483e6aa305a2b2395eabae554e51530e1d #v0.13.1
8331
- name: Create release and SBOM
8432
if: startsWith(github.ref, 'refs/tags/v')
85-
uses: goreleaser/goreleaser-action@v2
33+
uses: goreleaser/goreleaser-action@b508e2e3ef3b19d4e4146d4f8fb3ba9db644a757 #v3.2.0
8634
with:
8735
version: latest
88-
args: release --release-notes=deploy/release/notes.md --rm-dist --skip-validate
36+
args: release --rm-dist --skip-validate
8937
env:
9038
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
REPO_TOKEN: ${{ secrets.REPO_TOKEN }}

.github/workflows/scan.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ jobs:
1717
name: FOSSA
1818
runs-on: ubuntu-latest
1919
steps:
20-
- uses: actions/checkout@v2
20+
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3
2121
- name: Run FOSSA scan and upload build data
22-
uses: fossa-contrib/fossa-action@v1
22+
uses: fossa-contrib/fossa-action@6cffaa064112e1cf9b5798c6224f9487dc1ec316 #v1.2.0
2323
with:
2424
# FOSSA Push-Only API Token
2525
fossa-api-key: 956b9b92c5b16eeca1467cebe104f2c3
@@ -30,12 +30,12 @@ jobs:
3030
runs-on: ubuntu-latest
3131
steps:
3232
- name: Checkout repository
33-
uses: actions/checkout@v2
33+
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3
3434
- name: Initialize CodeQL
35-
uses: github/codeql-action/init@v1
35+
uses: github/codeql-action/init@c3b6fce4ee2ca25bc1066aa3bf73962fda0e8898 #codeql-bundle-20221020
3636
with:
3737
languages: go
3838
- name: Autobuild
39-
uses: github/codeql-action/autobuild@v1
39+
uses: github/codeql-action/autobuild@c3b6fce4ee2ca25bc1066aa3bf73962fda0e8898 #codeql-bundle-20221020
4040
- name: Perform CodeQL Analysis
41-
uses: github/codeql-action/analyze@v1
41+
uses: github/codeql-action/analyze@c3b6fce4ee2ca25bc1066aa3bf73962fda0e8898 #codeql-bundle-20221020

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
mongodb_query_exporter
2+
mongodb-query-exporter
23
goreportcard.db
34
./config.yaml
45
coverage.out

0 commit comments

Comments
 (0)