Skip to content

Commit 281e6f3

Browse files
core: update gha pipeline (#106)
1 parent 816e3ee commit 281e6f3

File tree

12 files changed

+173
-66
lines changed

12 files changed

+173
-66
lines changed

.github/workflows/prerelease.yml

Lines changed: 72 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,10 @@ on:
1010
env:
1111
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1212
GO_VERSION: '1.9.7'
13-
GPG_MAIL: '[email protected]'
14-
GPG_PASSPHRASE: ${{ secrets.OHAI_GPG_PASSPHRASE }}
15-
GPG_PRIVATE_KEY_BASE64: ${{ secrets.OHAI_GPG_PRIVATE_KEY_BASE64 }} # base64 encoded
1613
INTEGRATION: "redis"
1714
ORIGINAL_REPO_NAME: 'newrelic/nri-redis'
18-
PFX_CERTIFICATE_BASE64: ${{ secrets.OHAI_PFX_CERTIFICATE_BASE64 }} # base64 encoded
19-
PFX_CERTIFICATE_DESCRIPTION: 'New Relic'
20-
PFX_PASSPHRASE: ${{ secrets.OHAI_PFX_PASSPHRASE }}
2115
REPO_FULL_NAME: ${{ github.event.repository.full_name }}
22-
SLACK_TOKEN: ${{ secrets.OHAI_SLACK_TOKEN }}
23-
SLACK_CHANNEL: ${{ secrets.OHAI_SLACK_CHANNEL }}
24-
SNYK_TOKEN: ${{ secrets.COREINT_SNYK_TOKEN }}
2516
TAG: ${{ github.event.release.tag_name }}
26-
DOCKER_HUB_ID: ${{ secrets.OHAI_DOCKER_HUB_ID }}
27-
DOCKER_HUB_PASSWORD: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
2817

2918
jobs:
3019

@@ -36,8 +25,8 @@ jobs:
3625
- name: Login to DockerHub
3726
uses: docker/login-action@v1
3827
with:
39-
username: ${{ env.DOCKER_HUB_ID }}
40-
password: ${{ env.DOCKER_HUB_PASSWORD }}
28+
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
29+
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
4130
- name: Validate code
4231
run: make ci/validate
4332

@@ -49,9 +38,11 @@ jobs:
4938
- name: Login to DockerHub
5039
uses: docker/login-action@v1
5140
with:
52-
username: ${{ env.DOCKER_HUB_ID }}
53-
password: ${{ env.DOCKER_HUB_PASSWORD }}
41+
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
42+
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
5443
- name: Scan code for vulnerabilities
44+
env:
45+
SNYK_TOKEN: ${{ secrets.COREINT_SNYK_TOKEN }}
5546
run: make ci/snyk-test
5647

5748
test-nix:
@@ -62,8 +53,8 @@ jobs:
6253
- name: Login to DockerHub
6354
uses: docker/login-action@v1
6455
with:
65-
username: ${{ env.DOCKER_HUB_ID }}
66-
password: ${{ env.DOCKER_HUB_PASSWORD }}
56+
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
57+
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
6758
- name: Unit tests
6859
run: make ci/test
6960

@@ -88,7 +79,6 @@ jobs:
8879
shell: pwsh
8980
run: |
9081
.\build\windows\unit_tests.ps1
91-
9282
# can't run this step inside of container because of tests specific
9383
test-integration-nix:
9484
name: Run integration tests on *Nix
@@ -109,8 +99,8 @@ jobs:
10999
- name: Login to DockerHub
110100
uses: docker/login-action@v1
111101
with:
112-
username: ${{ env.DOCKER_HUB_ID }}
113-
password: ${{ env.DOCKER_HUB_PASSWORD }}
102+
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
103+
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
114104
- name: Integration test
115105
env:
116106
GOPATH: ${{ github.workspace }}
@@ -125,39 +115,43 @@ jobs:
125115
- name: Login to DockerHub
126116
uses: docker/login-action@v1
127117
with:
128-
username: ${{ env.DOCKER_HUB_ID }}
129-
password: ${{ env.DOCKER_HUB_PASSWORD }}
118+
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
119+
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
130120
- name: Pre release
131121
run: make ci/prerelease
132-
- name: Notify failure via Slack
133-
if: ${{ failure() }}
134-
uses: archive/github-actions-slack@master
135-
with:
136-
slack-bot-user-oauth-access-token: ${{ env.SLACK_TOKEN }}
137-
slack-channel: ${{ env.SLACK_CHANNEL }}
138-
slack-text: ":shit: Repo: ${{ env.REPO_FULL_NAME }}, prerelease for nix FAILURE!"
122+
env:
123+
GPG_MAIL: '[email protected]'
124+
GPG_PASSPHRASE: ${{ secrets.OHAI_GPG_PASSPHRASE }}
125+
GPG_PRIVATE_KEY_BASE64: ${{ secrets.OHAI_GPG_PRIVATE_KEY_BASE64 }} # base64 encoded
139126
- name: Test package installability
140127
uses: newrelic/integrations-pkg-test-action/linux@v1
141128
with:
142129
tag: ${{ env.TAG }}
143130
integration: nri-${{ env.INTEGRATION }}
131+
- name: Notify failure via Slack
132+
if: ${{ failure() }}
133+
uses: archive/github-actions-slack@master
134+
with:
135+
slack-bot-user-oauth-access-token: ${{ secrets.COREINT_SLACK_TOKEN }}
136+
slack-channel: ${{ secrets.COREINT_SLACK_CHANNEL }}
137+
slack-text: "❌ `${{ env.REPO_FULL_NAME }}`: prerelease pipeline failed."
144138

145139
package-win:
146140
name: Create MSI & Upload into GH Release assets
147141
runs-on: windows-2019
148142
needs: [prerelease]
149143
env:
150144
GOPATH: ${{ github.workspace }}
145+
PFX_CERTIFICATE_BASE64: ${{ secrets.OHAI_PFX_CERTIFICATE_BASE64 }} # base64 encoded
146+
PFX_CERTIFICATE_DESCRIPTION: 'New Relic'
147+
PFX_PASSPHRASE: ${{ secrets.OHAI_PFX_PASSPHRASE }}
151148
defaults:
152149
run:
153150
working-directory: src/github.com/${{env.ORIGINAL_REPO_NAME}}
154151
strategy:
155152
matrix:
156153
goarch: [amd64,386]
157154
test-upgrade: [true,false]
158-
exclude:
159-
- goarch: 386
160-
test-upgrade: true
161155
steps:
162156
- name: Checkout
163157
uses: actions/checkout@v2
@@ -190,6 +184,49 @@ jobs:
190184
if: ${{ failure() }}
191185
uses: archive/github-actions-slack@master
192186
with:
193-
slack-bot-user-oauth-access-token: ${{ env.SLACK_TOKEN }}
194-
slack-channel: ${{ env.SLACK_CHANNEL }}
195-
slack-text: ":shit: Repo: ${{ env.REPO_FULL_NAME }}, prerelease for Windows FAILURE!"
187+
slack-bot-user-oauth-access-token: ${{ secrets.COREINT_SLACK_TOKEN }}
188+
slack-channel: ${{ secrets.COREINT_SLACK_CHANNEL }}
189+
slack-text: "❌ `${{ env.REPO_FULL_NAME }}`: prerelease pipeline failed."
190+
191+
publish-to-s3:
192+
name: Send release assets to S3
193+
runs-on: ubuntu-20.04
194+
needs: [package-win]
195+
steps:
196+
- name: Login to DockerHub
197+
uses: docker/login-action@v1
198+
with:
199+
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
200+
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
201+
- name: Publish to S3 action
202+
uses: newrelic/infrastructure-publish-action@v1
203+
env:
204+
AWS_S3_BUCKET_NAME: "nr-downloads-ohai-staging"
205+
AWS_S3_LOCK_BUCKET_NAME: "onhost-ci-lock-staging"
206+
with:
207+
disable_lock: false
208+
run_id: ${{ github.run_id }}
209+
tag: ${{env.TAG}}
210+
app_name: "nri-${{env.INTEGRATION}}"
211+
repo_name: ${{ env.ORIGINAL_REPO_NAME }}
212+
# 'ohi' is for integrations
213+
schema: "ohi"
214+
aws_region: "us-east-1"
215+
aws_role_arn: ${{ secrets.OHAI_AWS_ROLE_ARN_STAGING }}
216+
aws_role_session_name: ${{ secrets.OHAI_AWS_ROLE_SESSION_NAME_STAGING }}
217+
aws_access_key_id: ${{ secrets.OHAI_AWS_ACCESS_KEY_ID_STAGING }}
218+
aws_secret_access_key: ${{ secrets.OHAI_AWS_SECRET_ACCESS_KEY_STAGING }}
219+
aws_s3_bucket_name: ${{ env.AWS_S3_BUCKET_NAME }}
220+
# used for locking in case of concurrent releases
221+
aws_s3_lock_bucket_name: ${{ env.AWS_S3_LOCK_BUCKET_NAME }}
222+
# used for signing package stuff
223+
gpg_passphrase: ${{ secrets.OHAI_GPG_PASSPHRASE }}
224+
gpg_private_key_base64: ${{ secrets.OHAI_GPG_PRIVATE_KEY_BASE64 }}
225+
- name: Test uploaded package installability
226+
uses: newrelic/integrations-pkg-test-action/linux@v1
227+
with:
228+
tag: ${{ env.TAG }}
229+
integration: nri-${{ env.INTEGRATION }}
230+
packageLocation: repo
231+
stagingRepo: true
232+
upgrade: false

.github/workflows/push_pr.yml

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,16 @@ name: Push/PR pipeline
33
on:
44
push:
55
branches:
6-
- '**'
7-
tags-ignore:
8-
- '**'
6+
- main
7+
- master
8+
pull_request:
99

1010
env:
1111
TAG: "v0.0.0" # needed for goreleaser windows builds
1212
REPO_FULL_NAME: ${{ github.event.repository.full_name }}
1313
ORIGINAL_REPO_NAME: "newrelic/nri-redis"
14-
SNYK_TOKEN: ${{ secrets.COREINT_SNYK_TOKEN }}
1514
GO_VERSION: '1.9.7'
16-
DOCKER_HUB_ID: ${{ secrets.OHAI_DOCKER_HUB_ID }}
17-
DOCKER_HUB_PASSWORD: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
15+
DOCKER_LOGIN_AVAILABLE: ${{ secrets.OHAI_DOCKER_HUB_ID }}
1816

1917
jobs:
2018

@@ -24,24 +22,30 @@ jobs:
2422
steps:
2523
- uses: actions/checkout@v2
2624
- name: Login to DockerHub
25+
if: ${{env.DOCKER_LOGIN_AVAILABLE}}
2726
uses: docker/login-action@v1
2827
with:
29-
username: ${{ env.DOCKER_HUB_ID }}
30-
password: ${{ env.DOCKER_HUB_PASSWORD }}
28+
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
29+
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
3130
- name: Validate code
3231
run: make ci/validate
3332

33+
3434
snyk:
3535
name: Run security checks via snyk
3636
runs-on: ubuntu-20.04
37+
env:
38+
SNYK_TOKEN: ${{ secrets.COREINT_SNYK_TOKEN }}
3739
steps:
3840
- uses: actions/checkout@v2
3941
- name: Login to DockerHub
42+
if: ${{env.DOCKER_LOGIN_AVAILABLE}}
4043
uses: docker/login-action@v1
4144
with:
42-
username: ${{ env.DOCKER_HUB_ID }}
43-
password: ${{ env.DOCKER_HUB_PASSWORD }}
45+
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
46+
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
4447
- name: Scan code for vulnerabilities
48+
if: ${{env.SNYK_TOKEN}}
4549
run: make ci/snyk-test
4650

4751
test-nix:
@@ -50,10 +54,11 @@ jobs:
5054
steps:
5155
- uses: actions/checkout@v2
5256
- name: Login to DockerHub
57+
if: ${{env.DOCKER_LOGIN_AVAILABLE}}
5358
uses: docker/login-action@v1
5459
with:
55-
username: ${{ env.DOCKER_HUB_ID }}
56-
password: ${{ env.DOCKER_HUB_PASSWORD }}
60+
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
61+
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
5762
- name: Unit tests
5863
run: make ci/test
5964

@@ -78,7 +83,6 @@ jobs:
7883
shell: pwsh
7984
run: |
8085
.\build\windows\unit_tests.ps1
81-
8286
# can't run this step inside of container because of tests specific
8387
test-integration-nix:
8488
name: Run integration tests on *Nix
@@ -97,10 +101,11 @@ jobs:
97101
with:
98102
go-version: ${{env.GO_VERSION}}
99103
- name: Login to DockerHub
104+
if: ${{env.DOCKER_LOGIN_AVAILABLE}}
100105
uses: docker/login-action@v1
101106
with:
102-
username: ${{ env.DOCKER_HUB_ID }}
103-
password: ${{ env.DOCKER_HUB_PASSWORD }}
107+
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
108+
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
104109
- name: Integration test
105110
env:
106111
GOPATH: ${{ github.workspace }}
@@ -112,9 +117,10 @@ jobs:
112117
steps:
113118
- uses: actions/checkout@v2
114119
- name: Login to DockerHub
120+
if: ${{env.DOCKER_LOGIN_AVAILABLE}}
115121
uses: docker/login-action@v1
116122
with:
117-
username: ${{ env.DOCKER_HUB_ID }}
118-
password: ${{ env.DOCKER_HUB_PASSWORD }}
123+
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
124+
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
119125
- name: Build all platforms:arch
120126
run: make ci/build

.github/workflows/release.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Release pipeline
2+
3+
on:
4+
release:
5+
types:
6+
- released
7+
tags:
8+
- 'v*'
9+
10+
env:
11+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12+
INTEGRATION: "redis"
13+
ORIGINAL_REPO_NAME: ${{ github.event.repository.full_name }}
14+
TAG: ${{ github.event.release.tag_name }}
15+
16+
jobs:
17+
18+
publish-to-s3:
19+
name: Send release assets to S3
20+
runs-on: ubuntu-20.04
21+
steps:
22+
- name: Login to DockerHub
23+
uses: docker/login-action@v1
24+
with:
25+
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
26+
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
27+
- name: Publish to S3 action
28+
uses: newrelic/infrastructure-publish-action@v1
29+
env:
30+
AWS_S3_BUCKET_NAME: "nr-downloads-main"
31+
AWS_S3_LOCK_BUCKET_NAME: "onhost-ci-lock"
32+
AWS_REGION: "us-east-1"
33+
with:
34+
# lock enabled
35+
disable_lock: false
36+
run_id: ${{ github.run_id }}
37+
tag: ${{env.TAG}}
38+
app_name: "nri-${{env.INTEGRATION}}"
39+
repo_name: ${{ env.ORIGINAL_REPO_NAME }}
40+
# 'ohi' is for integrations
41+
schema: "ohi"
42+
aws_region: ${{ env.AWS_REGION }}
43+
aws_role_arn: ${{ secrets.OHAI_AWS_ROLE_ARN_PRODUCTION }}
44+
aws_role_session_name: ${{ secrets.OHAI_AWS_ROLE_SESSION_NAME_PRODUCTION }}
45+
aws_access_key_id: ${{ secrets.OHAI_AWS_ACCESS_KEY_ID_PRODUCTION }}
46+
aws_secret_access_key: ${{ secrets.OHAI_AWS_SECRET_ACCESS_KEY_PRODUCTION }}
47+
aws_s3_bucket_name: ${{ env.AWS_S3_BUCKET_NAME }}
48+
# used for locking in case of concurrent releases
49+
aws_s3_lock_bucket_name: ${{ env.AWS_S3_LOCK_BUCKET_NAME }}
50+
# used for signing package stuff
51+
gpg_passphrase: ${{ secrets.OHAI_GPG_PASSPHRASE }}
52+
gpg_private_key_base64: ${{ secrets.OHAI_GPG_PRIVATE_KEY_BASE64 }}
53+
- name: Test package from prod repo
54+
uses: newrelic/integrations-pkg-test-action/linux@v1
55+
with:
56+
tag: ${{ env.TAG }}
57+
integration: 'nri-${{ env.INTEGRATION }}' # Required, with nri- prefix
58+
packageLocation: repo
59+
upgrade: false

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

8+
## 1.6.1 (2021-03-24)
9+
### Added
10+
- Add arm packages and binaries
11+
812
## 1.6.0 (2020-10-29)
913
### Added
10-
- Add print integration version from cli using.
14+
- Add print integration version from cli using `-show_version` flag
1115

1216
## 1.5.1 (2020-09-26)
1317
### Added

CODE_OF_CONDUCT.md

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

build/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM golang:1.15.2-buster
22

3-
ARG GH_VERSION='1.1.0'
3+
ARG GH_VERSION='1.4.0'
44

55
RUN apt-get update \
66
&& apt-get -y install \

build/ci.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ ci/snyk-test:
4242
-v $(CURDIR):/go/src/github.com/newrelic/nri-$(INTEGRATION) \
4343
-w /go/src/github.com/newrelic/nri-$(INTEGRATION) \
4444
-e SNYK_TOKEN \
45+
-e GO111MODULE=auto \
4546
snyk/snyk:golang snyk test --severity-threshold=high
4647

4748
.PHONY : ci/build

0 commit comments

Comments
 (0)