Skip to content

Commit 1a04071

Browse files
authored
CRT onboarding (#582)
1 parent 6f9c188 commit 1a04071

21 files changed

+811
-45
lines changed

.circleci/config.yml

+2-9
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,13 @@ jobs:
1818
- run: make generate-tools
1919
- run: make check
2020

21-
lint-go:
21+
linux-build-go:
2222
executor: go-linux
2323
steps:
2424
- checkout
2525
- run: make lint-tools
2626
- run: make generate-tools
27-
- run: make lint
28-
29-
linux-build-go:
30-
executor: go-linux
31-
steps:
32-
- checkout
33-
- run: make build
27+
- run: make dev
3428

3529
linux-test-go:
3630
executor: go-linux
@@ -43,6 +37,5 @@ workflows:
4337
ci:
4438
jobs:
4539
- check-deps-go
46-
- lint-go
4740
- linux-build-go
4841
- linux-test-go

.dockerignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
./bin/
2+
./plugins/test/bin/
3+
./pkg/
4+
.git

.github/CODEOWNERS

+4
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
# Blanket ownership of all PRs.
22
* @jazzyfresh @jrasell @lgfa29
3+
4+
# release configuration
5+
/.release/ @hashicorp/release-engineering
6+
/.github/workflows/build.yml @hashicorp/release-engineering

.github/workflows/build.yml

+225
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
name: build
2+
3+
on:
4+
push:
5+
workflow_dispatch:
6+
workflow_call:
7+
8+
env:
9+
PKG_NAME: "nomad-autoscaler"
10+
11+
jobs:
12+
get-go-version:
13+
name: "Determine Go toolchain version"
14+
runs-on: ubuntu-20.04
15+
outputs:
16+
go-version: ${{ steps.get-go-version.outputs.go-version }}
17+
steps:
18+
- uses: actions/checkout@v2
19+
- name: Determine Go version
20+
id: get-go-version
21+
run: |
22+
echo "Building with Go $(cat .go-version)"
23+
echo "::set-output name=go-version::$(cat .go-version)"
24+
25+
get-product-version:
26+
runs-on: ubuntu-20.04
27+
outputs:
28+
product-version: ${{ steps.get-product-version.outputs.product-version }}
29+
steps:
30+
- uses: actions/checkout@v2
31+
- name: get product version
32+
id: get-product-version
33+
run: |
34+
make version
35+
echo "::set-output name=product-version::$(make version)"
36+
37+
generate-metadata-file:
38+
needs: get-product-version
39+
runs-on: ubuntu-20.04
40+
outputs:
41+
filepath: ${{ steps.generate-metadata-file.outputs.filepath }}
42+
steps:
43+
- name: "Checkout directory"
44+
uses: actions/checkout@v2
45+
- name: Generate metadata file
46+
id: generate-metadata-file
47+
uses: hashicorp/actions-generate-metadata@v1
48+
with:
49+
version: ${{ needs.get-product-version.outputs.product-version }}
50+
product: ${{ env.PKG_NAME }}
51+
repositoryOwner: "hashicorp"
52+
- uses: actions/upload-artifact@v2
53+
if: ${{ !env.ACT }}
54+
with:
55+
name: metadata.json
56+
path: ${{ steps.generate-metadata-file.outputs.filepath }}
57+
58+
build-linux:
59+
needs:
60+
- get-go-version
61+
- get-product-version
62+
runs-on: ubuntu-20.04
63+
strategy:
64+
matrix:
65+
goos: ["linux"]
66+
goarch: ["386", "amd64", "arm", "arm64"]
67+
fail-fast: true
68+
69+
name: Go ${{ needs.get-go-version.outputs.go-version }} ${{ matrix.goos }} ${{ matrix.goarch }} build
70+
71+
steps:
72+
- uses: actions/checkout@v2
73+
- name: Setup go
74+
uses: actions/setup-go@v2
75+
with:
76+
go-version: ${{ needs.get-go-version.outputs.go-version }}
77+
- name: Build
78+
env:
79+
GOOS: ${{ matrix.goos }}
80+
GOARCH: ${{ matrix.goarch }}
81+
run: |
82+
make pkg/${{ matrix.goos }}_${{ matrix.goarch }}.zip
83+
mv \
84+
pkg/${{ matrix.goos }}_${{ matrix.goarch }}.zip \
85+
${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip
86+
- uses: actions/upload-artifact@v2
87+
if: ${{ !env.ACT }}
88+
with:
89+
name: ${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip
90+
path: ${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip
91+
- name: Package
92+
uses: hashicorp/actions-packaging-linux@v1
93+
with:
94+
name: "nomad-autoscaler"
95+
description: "Nomad Autoscaler brings autoscaling to your Nomad workloads."
96+
arch: ${{ matrix.goarch }}
97+
version: ${{ needs.get-product-version.outputs.product-version }}
98+
maintainer: "HashiCorp"
99+
homepage: "https://github.com/hashicorp/nomad-autoscaler"
100+
license: "MPL-2.0"
101+
binary: pkg/${{ matrix.goos }}_${{ matrix.goarch }}/${{ env.PKG_NAME }}
102+
deb_depends: "openssl"
103+
rpm_depends: "openssl"
104+
- name: Set Package Names
105+
if: ${{ !env.ACT }}
106+
run: |
107+
echo "RPM_PACKAGE=$(basename out/*.rpm)" >> $GITHUB_ENV
108+
echo "DEB_PACKAGE=$(basename out/*.deb)" >> $GITHUB_ENV
109+
- uses: actions/upload-artifact@v2
110+
if: ${{ !env.ACT }}
111+
with:
112+
name: ${{ env.RPM_PACKAGE }}
113+
path: out/${{ env.RPM_PACKAGE }}
114+
- uses: actions/upload-artifact@v2
115+
if: ${{ !env.ACT }}
116+
with:
117+
name: ${{ env.DEB_PACKAGE }}
118+
path: out/${{ env.DEB_PACKAGE }}
119+
120+
build-darwin:
121+
needs:
122+
- get-go-version
123+
- get-product-version
124+
runs-on: macos-11
125+
strategy:
126+
matrix:
127+
goos: ["darwin"]
128+
goarch: ["amd64", "arm64"]
129+
fail-fast: true
130+
131+
name: Go ${{ needs.get-go-version.outputs.go-version }} ${{ matrix.goos }} ${{ matrix.goarch }} build
132+
133+
steps:
134+
- uses: actions/checkout@v2
135+
- name: Setup go
136+
uses: actions/setup-go@v3
137+
with:
138+
go-version: ${{ needs.get-go-version.outputs.go-version }}
139+
- name: Build
140+
env:
141+
GOOS: ${{ matrix.goos }}
142+
GOARCH: ${{ matrix.goarch }}
143+
run: |
144+
make pkg/${{ matrix.goos }}_${{ matrix.goarch }}.zip
145+
mv \
146+
pkg/${{ matrix.goos }}_${{ matrix.goarch }}.zip \
147+
${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip
148+
- uses: actions/upload-artifact@v2
149+
if: ${{ !env.ACT }}
150+
with:
151+
name: ${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip
152+
path: ${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip
153+
154+
build-other:
155+
needs:
156+
- get-go-version
157+
- get-product-version
158+
runs-on: ubuntu-20.04
159+
strategy:
160+
matrix:
161+
goos: ["freebsd", "windows"]
162+
goarch: ["amd64", "arm", "arm64"]
163+
exclude:
164+
- goos: "windows"
165+
goarch: "arm"
166+
fail-fast: true
167+
168+
name: Go ${{ needs.get-go-version.outputs.go-version }} ${{ matrix.goos }} ${{ matrix.goarch }} build
169+
170+
steps:
171+
- uses: actions/checkout@v2
172+
- name: Setup go
173+
uses: actions/setup-go@v3
174+
with:
175+
go-version: ${{ needs.get-go-version.outputs.go-version }}
176+
- name: Build
177+
env:
178+
GOOS: ${{ matrix.goos }}
179+
GOARCH: ${{ matrix.goarch }}
180+
run: |
181+
make pkg/${{ matrix.goos }}_${{ matrix.goarch }}.zip
182+
mv \
183+
pkg/${{ matrix.goos }}_${{ matrix.goarch }}.zip \
184+
${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip
185+
- uses: actions/upload-artifact@v2
186+
if: ${{ !env.ACT }}
187+
with:
188+
name: ${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip
189+
path: ${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_${{ matrix.goos }}_${{ matrix.goarch }}.zip
190+
191+
build-docker-default:
192+
needs:
193+
- get-product-version
194+
- build-linux
195+
runs-on: ubuntu-20.04
196+
strategy:
197+
matrix:
198+
arch: ["arm", "arm64", "386", "amd64"]
199+
fail-fast: true
200+
env:
201+
version: ${{ needs.get-product-version.outputs.product-version }}
202+
203+
name: Docker ${{ matrix.arch }} default release build
204+
205+
steps:
206+
- uses: actions/checkout@v2
207+
- name: Docker Build (Action)
208+
uses: hashicorp/actions-docker-build@v1
209+
with:
210+
smoke_test: |
211+
TEST_VERSION="$(docker run "${IMAGE_NAME}" version | awk '/Nomad Autoscaler/{print $3}')"
212+
if [ "${TEST_VERSION}" != "v${version}" ]; then
213+
echo "Test FAILED"
214+
exit 1
215+
fi
216+
echo "Test PASSED"
217+
version: ${{ env.version }}
218+
target: release
219+
arch: ${{ matrix.arch }}
220+
tags: |
221+
docker.io/hashicorp/${{ env.PKG_NAME }}:${{ env.version }}
222+
986891699432.dkr.ecr.us-east-1.amazonaws.com/hashicorp/${{ env.PKG_NAME }}:${{ env.version }}
223+
dev_tags: |
224+
docker.io/hashicorppreview/${{ env.PKG_NAME }}:${{ env.version }}-dev
225+
docker.io/hashicorppreview/${{ env.PKG_NAME }}:${{ env.version }}-${{ github.sha }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Nightly releases are snapshots of the development activity on the Nomad Autoscaler project that may include new features and bug fixes scheduled for upcoming releases. These releases are made available to make it easier for users to test their existing build configurations against the latest Nomad Autoscaler code base for potential issues or to experiment with new features, with a chance to provide feedback on ways to improve the changes before being released.
2+
3+
As these releases are snapshots of the latest code, you may encounter an issue compared to the latest stable release. Users are encouraged to run nightly releases in a non production environment. If you encounter an issue, please check our [issue tracker](https://github.com/hashicorp/nomad-autoscaler/issues) to see if the issue has already been reported; if a report hasn't been made, please report it so we can review the issue and make any needed fixes.
4+
5+
**Note**: Nightly releases are only available via GitHub Releases, and artifacts are not codesigned or notarized. Distribution via other [Release Channels](https://www.hashicorp.com/official-release-channels) such as the Releases Site or Homebrew is not yet supported.

.github/workflows/nightly-release.yml

+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# This GitHub action triggers a fresh set of Nomad Autoscaler builds
2+
# and publishes them to GitHub Releases under the `nightly` tag.
3+
# Note that artifacts available via GitHub Releases are not codesigned or
4+
# notarized.
5+
# Failures are reported to slack.
6+
name: Nightly Release
7+
8+
on:
9+
schedule:
10+
# Runs against the default branch every day overnight
11+
- cron: "18 3 * * *"
12+
workflow_dispatch:
13+
14+
jobs:
15+
# Build a fresh set of artifacts
16+
build-artifacts:
17+
uses: ./.github/workflows/build.yml
18+
github-release:
19+
needs: build-artifacts
20+
runs-on: ubuntu-20.04
21+
steps:
22+
- uses: actions/checkout@v2
23+
- name: Download built artifacts
24+
uses: actions/download-artifact@v2
25+
with:
26+
path: out/
27+
# Set BUILD_OUTPUT_LIST to out\<project>-<version>.<fileext>\*,out\...
28+
# This is needed to attach the build artifacts to the GitHub Release
29+
- name: Set BUILD_OUTPUT_LIST
30+
run: |
31+
echo "$(ls -xm1 out/)" > tmp.txt
32+
cat tmp.txt | sed 's:.*:out/&/*:' > tmp2.txt
33+
echo "BUILD_OUTPUT_LIST=$(cat tmp2.txt | tr '\n' ',' | perl -ple 'chop')" >> $GITHUB_ENV
34+
rm -rf tmp.txt && rm -rf tmp2.txt
35+
- name: Advance nightly tag
36+
uses: actions/github-script@v3
37+
with:
38+
github-token: ${{ secrets.GITHUB_TOKEN }}
39+
script: |
40+
try {
41+
await github.git.deleteRef({
42+
owner: context.repo.owner,
43+
repo: context.repo.repo,
44+
ref: "tags/nightly"
45+
})
46+
} catch (e) {
47+
console.log("Warning: The nightly tag doesn't exist yet, so there's nothing to do. Trace: " + e)
48+
}
49+
await github.git.createRef({
50+
owner: context.repo.owner,
51+
repo: context.repo.repo,
52+
ref: "refs/tags/nightly",
53+
sha: context.sha
54+
})
55+
# This will create a new GitHub Release called `nightly`
56+
# If a release with this name already exists, it will overwrite the existing data
57+
- name: Create a nightly GitHub prerelease
58+
id: create_prerelease
59+
uses: ncipollo/release-action@v1
60+
with:
61+
name: nightly
62+
artifacts: "${{ env.BUILD_OUTPUT_LIST }}"
63+
tag: nightly
64+
bodyFile: ".github/workflows/nightly-release-readme.md"
65+
prerelease: true
66+
allowUpdates: true
67+
removeArtifacts: true
68+
draft: false
69+
token: ${{ secrets.GITHUB_TOKEN }}
70+
- name: Publish nightly GitHub prerelease
71+
uses: eregon/publish-release@v1
72+
env:
73+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
74+
with:
75+
release_id: ${{ steps.create_prerelease.outputs.id }}
76+
# Send a slack notification if either job defined above fails
77+
slack-notify:
78+
needs:
79+
- build-artifacts
80+
- github-release
81+
if: always() && (needs.build-artifacts.result == 'failure' || needs.github-release.result == 'failure')
82+
runs-on: ubuntu-20.04
83+
steps:
84+
- name: Send slack notification on failure
85+
uses: slackapi/[email protected]
86+
with:
87+
payload: |
88+
{
89+
"text": ":x::moon::nomad-sob: Nomad Autoscaler Nightly Release *FAILED*",
90+
"attachments": [
91+
{
92+
"color": "#C41E3A",
93+
"blocks": [
94+
{
95+
"type": "section",
96+
"fields": [
97+
{
98+
"type": "mrkdwn",
99+
"text": "*Branch:*\n`${{ github.ref_name }}`"
100+
},
101+
{
102+
"type": "mrkdwn",
103+
"text": "*Ref:*\n${{ github.sha }}"
104+
}
105+
]
106+
},
107+
{
108+
"type": "section",
109+
"fields": [
110+
{
111+
"type": "mrkdwn",
112+
"text": "*Workflow:*\n${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
113+
}
114+
]
115+
}
116+
]
117+
}
118+
]
119+
}
120+
env:
121+
# the slack webhook url links to #feed-nomad-releases
122+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
123+
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK

0 commit comments

Comments
 (0)