Skip to content

Commit 61e6f25

Browse files
chore(ci): leverage reusable workflow (#145)
* chore(ci): leverage reusable workflow
1 parent 58512e9 commit 61e6f25

7 files changed

Lines changed: 19 additions & 347 deletions

File tree

Lines changed: 7 additions & 212 deletions
Original file line numberDiff line numberDiff line change
@@ -1,220 +1,15 @@
1-
name: Create prerelease artifacts
2-
1+
name: Prerelease pipeline
32
on:
43
release:
54
types:
65
- prereleased
76
tags:
87
- 'v*'
98

10-
env:
11-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12-
INTEGRATION: "mysql"
13-
ORIGINAL_REPO_NAME: ${{ github.event.repository.full_name }}
14-
REPO_FULL_NAME: ${{ github.event.repository.full_name }}
15-
TAG: ${{ github.event.release.tag_name }}
16-
179
jobs:
18-
snyk:
19-
name: Run security checks via snyk
20-
runs-on: ubuntu-22.04
21-
steps:
22-
- uses: actions/checkout@v4
23-
- name: Login to DockerHub
24-
uses: docker/login-action@v2
25-
with:
26-
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
27-
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
28-
- name: Scan code for vulnerabilities
29-
env:
30-
SNYK_TOKEN: ${{ secrets.COREINT_SNYK_TOKEN }}
31-
run: make ci/snyk-test
32-
33-
test-nix:
34-
name: Run unit tests on *Nix
35-
runs-on: ubuntu-22.04
36-
steps:
37-
- uses: actions/checkout@v4
38-
- name: Login to DockerHub
39-
uses: docker/login-action@v2
40-
with:
41-
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
42-
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
43-
- name: Unit tests
44-
run: make ci/test
45-
46-
test-windows:
47-
name: Run unit tests on Windows
48-
runs-on: windows-2022
49-
env:
50-
GOPATH: ${{ github.workspace }}
51-
defaults:
52-
run:
53-
working-directory: src/github.com/${{env.ORIGINAL_REPO_NAME}}
54-
steps:
55-
- name: Checkout
56-
uses: actions/checkout@v4
57-
with:
58-
path: src/github.com/${{env.ORIGINAL_REPO_NAME}}
59-
- name: Install Go
60-
uses: actions/setup-go@v4
61-
with:
62-
go-version-file: "src/github.com/${{ env.ORIGINAL_REPO_NAME }}/go.mod"
63-
- name: Running unit tests
64-
shell: pwsh
65-
run: |
66-
.\build\windows\unit_tests.ps1
67-
68-
# can't run this step inside of container because of tests specific
69-
70-
test-integration-nix:
71-
name: Run integration tests on *Nix
72-
runs-on: ubuntu-22.04
73-
defaults:
74-
run:
75-
working-directory: src/github.com/${{env.ORIGINAL_REPO_NAME}}
76-
steps:
77-
- name: Check out code
78-
uses: actions/checkout@v4
79-
with:
80-
fetch-depth: 1
81-
path: src/github.com/${{env.ORIGINAL_REPO_NAME}}
82-
- name: Install Go
83-
uses: actions/setup-go@v4
84-
with:
85-
go-version-file: "src/github.com/${{ env.ORIGINAL_REPO_NAME }}/go.mod"
86-
- name: Login to DockerHub
87-
uses: docker/login-action@v2
88-
with:
89-
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
90-
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
91-
- name: Integration test
92-
env:
93-
GOPATH: ${{ github.workspace }}
94-
run: make integration-test
95-
96-
prerelease:
97-
name: Build binary for *Nix/Win, create archives for *Nix/Win, create packages for *Nix, upload all artifacts into GH Release assets
98-
runs-on: ubuntu-22.04
99-
needs: [snyk, test-nix, test-windows, test-integration-nix]
100-
steps:
101-
- uses: actions/checkout@v4
102-
- name: Login to DockerHub
103-
uses: docker/login-action@v2
104-
with:
105-
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
106-
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
107-
- name: Pre release
108-
run: make ci/prerelease
109-
env:
110-
GPG_MAIL: 'infrastructure-eng@newrelic.com'
111-
GPG_PASSPHRASE: ${{ secrets.OHAI_GPG_PASSPHRASE }}
112-
GPG_PRIVATE_KEY_BASE64: ${{ secrets.OHAI_GPG_PRIVATE_KEY_BASE64 }} # base64 encoded
113-
- name: Test package installability
114-
uses: newrelic/integrations-pkg-test-action/linux@v1
115-
with:
116-
tag: ${{ env.TAG }}
117-
integration: nri-${{ env.INTEGRATION }}
118-
119-
package-win:
120-
name: Create MSI & Upload into GH Release assets
121-
runs-on: windows-2022
122-
needs: [prerelease]
123-
env:
124-
GOPATH: ${{ github.workspace }}
125-
PFX_CERTIFICATE_BASE64: ${{ secrets.OHAI_PFX_CERTIFICATE_BASE64 }} # base64 encoded
126-
PFX_PASSPHRASE: ${{ secrets.OHAI_PFX_PASSPHRASE }}
127-
PFX_CERTIFICATE_DESCRIPTION: 'New Relic'
128-
defaults:
129-
run:
130-
working-directory: src/github.com/${{env.ORIGINAL_REPO_NAME}}
131-
strategy:
132-
matrix:
133-
goarch: [amd64,386]
134-
test-upgrade: [true,false]
135-
steps:
136-
- name: Checkout
137-
uses: actions/checkout@v4
138-
with:
139-
path: src/github.com/${{env.ORIGINAL_REPO_NAME}}
140-
- name: Get PFX certificate from GH secrets
141-
shell: bash
142-
run: printf "%s" "$PFX_CERTIFICATE_BASE64" | base64 -d - > wincert.pfx
143-
- name: Download zip from GH Release assets and extract .exe
144-
shell: pwsh
145-
run: |
146-
build\windows\download_zip_extract_exe.ps1 "$env:INTEGRATION" ${{ matrix.goarch }} "$env:TAG" "$env:REPO_FULL_NAME"
147-
- name: Create MSI
148-
shell: pwsh
149-
run: |
150-
build\windows\package_msi.ps1 -integration "$env:INTEGRATION" -arch ${{ matrix.goarch }} -tag "$env:TAG" -pfx_passphrase "$env:PFX_PASSPHRASE" -pfx_certificate_description "$env:PFX_CERTIFICATE_DESCRIPTION"
151-
- name: Test win packages installation
152-
uses: newrelic/integrations-pkg-test-action/windows@v1
153-
with:
154-
tag: ${{ env.TAG }}
155-
integration: nri-${{ env.INTEGRATION }}
156-
arch: ${{ matrix.goarch }}
157-
upgrade: ${{ matrix.test-upgrade }}
158-
- name: Upload MSI to GH
159-
# To avoid upload packages twice
160-
if: startsWith(matrix.test-upgrade, 'false')
161-
shell: bash
162-
run: |
163-
build/windows/upload_msi.sh ${INTEGRATION} ${{ matrix.goarch }} ${TAG}
164-
165-
publish-to-s3:
166-
name: Send release assets to S3
167-
runs-on: ubuntu-22.04
168-
needs: [package-win]
169-
steps:
170-
- name: Login to DockerHub
171-
uses: docker/login-action@v2
172-
with:
173-
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
174-
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
175-
- name: Publish to S3 action
176-
uses: newrelic/infrastructure-publish-action@v1
177-
env:
178-
AWS_S3_BUCKET_NAME: "nr-downloads-ohai-staging"
179-
AWS_S3_LOCK_BUCKET_NAME: "onhost-ci-lock-staging"
180-
with:
181-
disable_lock: false
182-
run_id: ${{ github.run_id }}
183-
tag: ${{env.TAG}}
184-
app_name: "nri-${{env.INTEGRATION}}"
185-
repo_name: ${{ env.ORIGINAL_REPO_NAME }}
186-
access_point_host: "staging"
187-
# 'ohi' is for integrations
188-
schema: "ohi"
189-
aws_region: "us-east-1"
190-
aws_role_arn: ${{ secrets.OHAI_AWS_ROLE_ARN_STAGING }}
191-
aws_role_session_name: ${{ secrets.OHAI_AWS_ROLE_SESSION_NAME_STAGING }}
192-
aws_access_key_id: ${{ secrets.OHAI_AWS_ACCESS_KEY_ID_STAGING }}
193-
aws_secret_access_key: ${{ secrets.OHAI_AWS_SECRET_ACCESS_KEY_STAGING }}
194-
aws_s3_bucket_name: ${{ env.AWS_S3_BUCKET_NAME }}
195-
# used for locking in case of concurrent releases
196-
aws_s3_lock_bucket_name: ${{ env.AWS_S3_LOCK_BUCKET_NAME }}
197-
# used for signing package stuff
198-
gpg_passphrase: ${{ secrets.OHAI_GPG_PASSPHRASE }}
199-
gpg_private_key_base64: ${{ secrets.OHAI_GPG_PRIVATE_KEY_BASE64 }}
200-
- name: Test uploaded package installability
201-
uses: newrelic/integrations-pkg-test-action/linux@v1
202-
with:
203-
tag: ${{ env.TAG }}
204-
integration: nri-${{ env.INTEGRATION }}
205-
packageLocation: repo
206-
stagingRepo: true
207-
upgrade: false
208-
209-
210-
notify-failure:
211-
if: ${{ always() && failure() }}
212-
needs: [snyk, test-nix, test-windows, test-integration-nix, prerelease, package-win, publish-to-s3]
213-
runs-on: ubuntu-latest
214-
steps:
215-
- name: Notify failure via Slack
216-
uses: archive/github-actions-slack@master
217-
with:
218-
slack-bot-user-oauth-access-token: ${{ secrets.COREINT_SLACK_TOKEN }}
219-
slack-channel: ${{ secrets.COREINT_SLACK_CHANNEL }}
220-
slack-text: "❌ `${{ env.ORIGINAL_REPO_NAME }}`: [prerelease pipeline failed](${{ github.server_url }}/${{ env.ORIGINAL_REPO_NAME }}/actions/runs/${{ github.run_id }})."
10+
pre-release:
11+
uses: newrelic/coreint-automation/.github/workflows/reusable_pre_release.yaml@v2
12+
with:
13+
tag: ${{ github.event.release.tag_name }}
14+
integration: mysql
15+
secrets: inherit

.github/workflows/on_push_pr.yaml

Lines changed: 6 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,15 @@
1-
name: Push/PR
2-
31
on:
42
push:
53
branches:
64
- main
75
- master
86
- renovate/**
97
pull_request:
10-
11-
env:
12-
TAG: "v0.0.0" # needed for goreleaser windows builds
13-
REPO_FULL_NAME: ${{ github.event.repository.full_name }}
14-
ORIGINAL_REPO_NAME: "newrelic/nri-mysql"
15-
DOCKER_LOGIN_AVAILABLE: ${{ secrets.OHAI_DOCKER_HUB_ID }}
8+
workflow_dispatch:
169

1710
jobs:
18-
static-analysis:
19-
name: Run all static analysis checks
20-
runs-on: ubuntu-22.04
21-
steps:
22-
- uses: actions/checkout@v4
23-
- uses: newrelic/newrelic-infra-checkers@v1
24-
- name: golangci-lint
25-
uses: golangci/golangci-lint-action@v3
26-
continue-on-error: ${{ github.event_name != 'pull_request' }}
27-
with:
28-
only-new-issues: true
29-
- name: Check if CHANGELOG is valid
30-
uses: newrelic/release-toolkit/validate-markdown@v1
31-
32-
snyk:
33-
name: Run security checks via snyk
34-
runs-on: ubuntu-22.04
35-
env:
36-
SNYK_TOKEN: ${{ secrets.COREINT_SNYK_TOKEN }}
37-
steps:
38-
- uses: actions/checkout@v4
39-
- name: Login to DockerHub
40-
if: ${{env.DOCKER_LOGIN_AVAILABLE}}
41-
uses: docker/login-action@v2
42-
with:
43-
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
44-
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
45-
- name: Scan code for vulnerabilities
46-
if: ${{env.SNYK_TOKEN}}
47-
run: make ci/snyk-test
48-
49-
test-nix:
50-
name: Run unit tests on *Nix
51-
runs-on: ubuntu-22.04
52-
steps:
53-
- uses: actions/checkout@v4
54-
- name: Login to DockerHub
55-
if: ${{env.DOCKER_LOGIN_AVAILABLE}}
56-
uses: docker/login-action@v2
57-
with:
58-
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
59-
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
60-
- name: Unit tests
61-
run: make ci/test
62-
63-
test-windows:
64-
name: Run unit tests on Windows
65-
runs-on: windows-2022
66-
env:
67-
GOPATH: ${{ github.workspace }}
68-
defaults:
69-
run:
70-
working-directory: src/github.com/${{env.ORIGINAL_REPO_NAME}}
71-
steps:
72-
- name: Checkout
73-
uses: actions/checkout@v4
74-
with:
75-
path: src/github.com/${{env.ORIGINAL_REPO_NAME}}
76-
- name: Install Go
77-
uses: actions/setup-go@v4
78-
with:
79-
go-version-file: "src/github.com/${{ env.ORIGINAL_REPO_NAME }}/go.mod"
80-
- name: Running unit tests
81-
shell: pwsh
82-
run: |
83-
.\build\windows\unit_tests.ps1
84-
85-
# can't run this step inside of container because of tests specific
86-
test-integration-nix:
87-
name: Run integration tests on *Nix
88-
runs-on: ubuntu-22.04
89-
defaults:
90-
run:
91-
working-directory: src/github.com/${{env.ORIGINAL_REPO_NAME}}
92-
steps:
93-
- name: Check out code
94-
uses: actions/checkout@v4
95-
with:
96-
fetch-depth: 1
97-
path: src/github.com/${{env.ORIGINAL_REPO_NAME}}
98-
- name: Install Go
99-
uses: actions/setup-go@v4
100-
with:
101-
go-version-file: "src/github.com/${{ env.ORIGINAL_REPO_NAME }}/go.mod"
102-
- name: Login to DockerHub
103-
if: ${{env.DOCKER_LOGIN_AVAILABLE}}
104-
uses: docker/login-action@v2
105-
with:
106-
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
107-
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
108-
- name: Integration test
109-
env:
110-
GOPATH: ${{ github.workspace }}
111-
run: make integration-test
112-
113-
test-build:
114-
name: Test binary compilation for all platforms:arch
115-
runs-on: ubuntu-22.04
116-
steps:
117-
- uses: actions/checkout@v4
118-
- name: Login to DockerHub
119-
if: ${{env.DOCKER_LOGIN_AVAILABLE}}
120-
uses: docker/login-action@v2
121-
with:
122-
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
123-
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
124-
- name: Build all platforms:arch
125-
run: make ci/build
11+
push-pr:
12+
uses: newrelic/coreint-automation/.github/workflows/reusable_push_pr.yaml@v2
13+
with:
14+
integration: mysql
15+
secrets: inherit

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ Unreleased section should follow [Release Toolkit](https://github.com/newrelic/r
99

1010
## Unreleased
1111

12+
### bugfix
13+
- Updated golang to version v1.21.7 to fix a vulnerability
14+
1215
## v1.10.4 - 2024-02-26
1316

1417
### ⛓️ Dependencies

build/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.21.3-bookworm
1+
FROM golang:1.21.7-bookworm
22

33
ARG GH_VERSION='1.9.2'
44

go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/newrelic/nri-mysql
22

3-
go 1.21
3+
go 1.21.7
44

55
require (
66
github.com/bitly/go-simplejson v0.5.1
@@ -12,9 +12,7 @@ require (
1212
)
1313

1414
require (
15-
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 // indirect
1615
github.com/davecgh/go-spew v1.1.1 // indirect
17-
github.com/kr/pretty v0.2.1 // indirect
1816
github.com/kr/text v0.2.0 // indirect
1917
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
2018
github.com/pkg/errors v0.9.1 // indirect

0 commit comments

Comments
 (0)