-
Notifications
You must be signed in to change notification settings - Fork 7
176 lines (166 loc) · 6.73 KB
/
pr.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
### On Pr creation against main
###
### checking_pr
### +-----------------------+
### | |
### | Runs sanity checks |
### | |
### | Tests Packages linux |
### | if enabled |
### | |
### +-----------------------+
on:
pull_request:
branches: [ main ]
push:
branches:
- renovate/**
env:
GPG_MAIL: '[email protected]'
OHAI_PFX_CERTIFICATE_BASE64: ${{ secrets.OHAI_PFX_CERTIFICATE_BASE64 }} # base64 encoded
OHAI_PFX_PASSPHRASE: ${{ secrets.OHAI_PFX_PASSPHRASE }}
GORELEASER_VERSION: 'v1.13.1'
###
### Checking PR # Checks the file and the info provided when an exporter is modified
###
name: Checking PR
jobs:
check_exporter_preconditions:
name: Test exporter e2e and output exporter variables
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version-file: nri-config-generator/go.mod
- name: Check if exporters have been modified
id: check
# Running shouldDoRelease we check if any exporter.yml has been modified, if so we set CREATE_RELEASE to true setting the variable EXPORTER_PATH
# That variable is used by the following step and jobs
run : |
source ./scripts/common_functions.sh
shouldDoRelease
loadVariables $EXPORTER_PATH
setStepOutput
outputs:
CREATE_RELEASE: ${{ steps.check.outputs.CREATE_RELEASE }}
EXPORTER_PATH: ${{ steps.check.outputs.EXPORTER_PATH }}
PACKAGE_LINUX: ${{ steps.check.outputs.PACKAGE_LINUX }}
PACKAGE_WINDOWS: ${{ steps.check.outputs.PACKAGE_WINDOWS }}
INTEGRATION_NAME: ${{ steps.check.outputs.NAME }}
INTEGRATION_VERSION: ${{ steps.check.outputs.VERSION }}
RELEASE_TAG: ${{ steps.check.outputs.PACKAGE_NAME }}-${{ steps.check.outputs.VERSION }}
EXPORTER_REPO_URL: ${{ steps.check.outputs.EXPORTER_REPO_URL }}
EXPORTER_HEAD: ${{ steps.check.outputs.EXPORTER_HEAD }}
EXPORTER_CHANGELOG: ${{ steps.check.outputs.EXPORTER_CHANGELOG }}
checking_pr:
name: Checking PR
runs-on: ubuntu-latest
needs: [check_exporter_preconditions]
if: ${{ needs.check_exporter_preconditions.outputs.CREATE_RELEASE == 'true' && needs.check_exporter_preconditions.outputs.PACKAGE_LINUX == 'true'}}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version-file: nri-config-generator/go.mod
- name: Install goreleaser
uses: goreleaser/goreleaser-action@v4
with:
version: ${{ env.GORELEASER_VERSION }}
install-only: true
- name: Compile exporter
run : |
make build-${{ needs.check_exporter_preconditions.outputs.INTEGRATION_NAME }}
- name: e2e-test
uses: newrelic/newrelic-integration-e2e-action@v1
with:
spec_path: exporters/${{ needs.check_exporter_preconditions.outputs.INTEGRATION_NAME }}/e2e/e2e_spec.yml
account_id: ${{ secrets.COREINT_E2E_ACCOUNT_ID }}
api_key: ${{ secrets.COREINT_E2E_API_KEY }}
license_key: ${{ secrets.COREINT_E2E_LICENSE_KEY }}
build_linux_artifacts:
name: Build Linux artifacts and packages
runs-on: ubuntu-latest
needs: [check_exporter_preconditions]
if: ${{ needs.check_exporter_preconditions.outputs.CREATE_RELEASE == 'true' && needs.check_exporter_preconditions.outputs.PACKAGE_LINUX == 'true'}}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version-file: nri-config-generator/go.mod
- name: Install goreleaser
uses: goreleaser/goreleaser-action@v4
with:
version: ${{ env.GORELEASER_VERSION }}
install-only: true
- name: Install dependencies
run: |
sudo apt-get install rpm ruby ruby-dev rubygems build-essential rpm gnupg2 gpg-agent debsigs
sudo gem install --no-document fpm
- name: Package linux
id: package
env:
GPG_PASSPHRASE: ${{ secrets.OHAI_GPG_PASSPHRASE }}
GPG_PRIVATE_KEY_BASE64: ${{ secrets.OHAI_GPG_PRIVATE_KEY_BASE64 }} # base64 encoded
run : |
make package-${{ needs.check_exporter_preconditions.outputs.INTEGRATION_NAME }}
- name: Test package installability
uses: newrelic/integrations-pkg-test-action/linux@v1
with:
tag: ${{ needs.check_exporter_preconditions.outputs.INTEGRATION_VERSION }}
integration: nri-${{ needs.check_exporter_preconditions.outputs.INTEGRATION_NAME }}
upgrade: false
pkgDir: ./exporters/${{ needs.check_exporter_preconditions.outputs.INTEGRATION_NAME }}/target/packages/
build_windows_artifacts:
name: Build Windows artifacts and packages
runs-on: windows-latest
needs: [check_exporter_preconditions]
if: ${{ needs.check_exporter_preconditions.outputs.CREATE_RELEASE == 'true' && needs.check_exporter_preconditions.outputs.PACKAGE_WINDOWS == 'true' }}
env:
GOPATH: ${{ github.workspace }}
GOOS: windows
defaults:
run:
working-directory: src/repo
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: src/repo
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version-file: src/repo/nri-config-generator/go.mod
- name: Install goreleaser
uses: goreleaser/goreleaser-action@v4
with:
version: ${{ env.GORELEASER_VERSION }}
install-only: true
- name: Install dependencies
shell: bash
run: |
choco install yq
- name: Get PFX certificate from GH secrets
shell: bash
run: printf "%s" "$OHAI_PFX_CERTIFICATE_BASE64" | base64 -d - > mycert.pfx
- name: Build windows binary
id: package
shell: bash
run : |
make package-${{ needs.check_exporter_preconditions.outputs.INTEGRATION_NAME }}
- name: Test win packages installation
uses: newrelic/integrations-pkg-test-action/windows@v1
with:
tag: ${{ needs.check_exporter_preconditions.outputs.INTEGRATION_VERSION }}
integration: nri-${{ needs.check_exporter_preconditions.outputs.INTEGRATION_NAME }}
arch: amd64
pkgDir: ${{ github.workspace }}\src\repo\exporters\${{ needs.check_exporter_preconditions.outputs.INTEGRATION_NAME }}\target\packages
pkgName: nri-${{ needs.check_exporter_preconditions.outputs.INTEGRATION_NAME }}-amd64.${{ needs.check_exporter_preconditions.outputs.INTEGRATION_VERSION }}.msi
upgrade: false