Skip to content

Commit c8fc2e6

Browse files
authored
chore(build): remove duplication in build steps (#9832)
1 parent f5fe6c2 commit c8fc2e6

File tree

5 files changed

+84
-67
lines changed

5 files changed

+84
-67
lines changed

.github/workflows/build.yml

+7-19
Original file line numberDiff line numberDiff line change
@@ -24,49 +24,35 @@ jobs:
2424
- uses: actions/setup-node@v1
2525
with:
2626
node-version: ${{ env.NODE_VERSION }}
27+
2728
- name: Get yarn cache
2829
id: yarn-cache
2930
run: echo "::set-output name=dir::$(yarn cache dir)"
31+
3032
- uses: actions/cache@v1
3133
with:
3234
path: ${{ steps.yarn-cache.outputs.dir }}
3335
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
3436
restore-keys: |
3537
${{ runner.os }}-yarn-
36-
- name: Install Dependencies
37-
run: yarn --frozen-lockfile
38-
- name: Eslint Plugin Build
39-
run: |
40-
cd packages/eslint-plugin
41-
yarn tsc
42-
yarn test
43-
- name: Assert - no lint violations
44-
run: yarn lint
45-
- name: Assert - code is formatted
46-
run: yarn prettier:check
47-
- name: Build Modules
48-
run: yarn modules
49-
- name: Unit Tests
50-
run: yarn test --single-run
51-
- name: Functional Tests
52-
run: yarn functional
53-
- name: Yarn Build
54-
run: yarn build
5538
5639
- uses: actions/setup-java@v2
5740
with:
5841
java-version: 11
5942
distribution: 'zulu'
6043
cache: 'gradle'
44+
6145
- name: Prepare build variables
6246
id: build_variables
6347
run: |
6448
echo ::set-output name=REPO::${GITHUB_REPOSITORY##*/}
6549
echo ::set-output name=VERSION::"$(git describe --tags --abbrev=0 --match="v[0-9]*" | cut -c2-)-dev-${GITHUB_REF_NAME}-$(git rev-parse --short HEAD)-$(date --utc +'%Y%m%d%H%M')"
50+
6651
- name: Build
6752
env:
6853
ORG_GRADLE_PROJECT_version: ${{ steps.build_variables.outputs.VERSION }}
6954
run: ./gradlew build --stacktrace
55+
7056
- name: Login to GAR
7157
# Only run this on repositories in the 'spinnaker' org, not on forks.
7258
if: startsWith(github.repository, 'spinnaker/')
@@ -76,6 +62,7 @@ jobs:
7662
registry: us-docker.pkg.dev
7763
username: _json_key
7864
password: ${{ secrets.GAR_JSON_KEY }}
65+
7966
- name: Build and publish slim container image
8067
# Only run this on repositories in the 'spinnaker' org, not on forks.
8168
if: startsWith(github.repository, 'spinnaker/')
@@ -89,6 +76,7 @@ jobs:
8976
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-unvalidated"
9077
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ github.ref_name }}-latest-unvalidated-slim"
9178
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-unvalidated-slim"
79+
9280
- name: Build and publish ubuntu container image
9381
# Only run this on repositories in the 'spinnaker' org, not on forks.
9482
if: startsWith(github.repository, 'spinnaker/')

.github/workflows/package-bump-pr.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ jobs:
7979
8080
---
8181
82-
This Pr bumps each package to the next semver version (patch/minor/major) based on the commit messages of unpublished changes using [Conventional Commits](https://conventionalcommits.org).
82+
This PR bumps each package to the next semver version (patch/minor/major) based on the commit messages of unpublished changes using [Conventional Commits](https://conventionalcommits.org).
8383
8484
- fix: patch release
8585
- feat: minor release

.github/workflows/pr.yml

+6-19
Original file line numberDiff line numberDiff line change
@@ -17,49 +17,35 @@ jobs:
1717
- uses: actions/setup-node@v1
1818
with:
1919
node-version: ${{ env.NODE_VERSION }}
20+
2021
- name: Get yarn cache
2122
id: yarn-cache
2223
run: echo "::set-output name=dir::$(yarn cache dir)"
24+
2325
- uses: actions/cache@v1
2426
with:
2527
path: ${{ steps.yarn-cache.outputs.dir }}
2628
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
2729
restore-keys: |
2830
${{ runner.os }}-yarn-
29-
- name: Install Dependencies
30-
run: yarn --frozen-lockfile
31-
- name: Eslint Plugin Build
32-
run: |
33-
cd packages/eslint-plugin
34-
yarn tsc
35-
yarn test
36-
- name: Assert - no lint violations
37-
run: yarn lint
38-
- name: Assert - code is formatted
39-
run: yarn prettier:check
40-
- name: Build Modules
41-
run: yarn modules
42-
- name: Unit Tests
43-
run: yarn test --single-run
44-
- name: Functional Tests
45-
run: yarn functional
46-
- name: Yarn Build
47-
run: yarn build
4831
4932
- uses: actions/setup-java@v2
5033
with:
5134
java-version: 11
5235
distribution: 'zulu'
5336
cache: 'gradle'
37+
5438
- name: Prepare build variables
5539
id: build_variables
5640
run: |
5741
echo ::set-output name=REPO::${GITHUB_REPOSITORY##*/}
5842
echo ::set-output name=VERSION::"$(git describe --tags --abbrev=0 --match="v[0-9]*" | cut -c2-)-dev-pr-$(git rev-parse --short HEAD)-$(date --utc +'%Y%m%d%H%M')"
43+
5944
- name: Build
6045
env:
6146
ORG_GRADLE_PROJECT_version: ${{ steps.build_variables.outputs.VERSION }}
6247
run: ./gradlew build
48+
6349
- name: Build slim container image
6450
uses: docker/build-push-action@v2
6551
with:
@@ -70,6 +56,7 @@ jobs:
7056
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}"
7157
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:latest-slim"
7258
"${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.build_variables.outputs.VERSION }}-slim"
59+
7360
- name: Build ubuntu container image
7461
uses: docker/build-push-action@v2
7562
with:

build.gradle

+69-27
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
plugins {
2-
id "io.spinnaker.artifactregistry-publish" version "$spinnakerGradleVersion"
3-
id "nebula.node" version "1.3.1"
4-
}
5-
61
import java.nio.file.Paths
72
import groovy.json.JsonOutput
83
import groovy.json.JsonSlurper
94
import org.redline_rpm.header.Flags
105

6+
plugins {
7+
id "io.spinnaker.artifactregistry-publish" version "$spinnakerGradleVersion"
8+
id "nebula.node" version "1.3.1"
9+
}
1110

1211
group = "com.netflix.spinnaker.deck"
1312
apply plugin: "nebula.ospackage"
@@ -27,32 +26,48 @@ node {
2726

2827
task modules(type: YarnTask) {
2928
dependsOn "yarn"
29+
3030
yarnCommand = ["modules"]
3131
}
3232

33-
task webpack(type: YarnTask) {
34-
dependsOn "yarn"
33+
task eslintPluginCompile(type: YarnTask) {
3534
dependsOn "modules"
36-
dependsOn "test"
3735

38-
yarnCommand = ["build"]
39-
environment = [
40-
"NODE_ENV": "production",
41-
"GATE_HOST": "spinnaker-api-prestaging.prod.netflix.net",
42-
"NODE_OPTIONS": "--max_old_space_size=8192",
43-
]
36+
workingDir = file(Paths.get("packages", "eslint-plugin"))
37+
yarnCommand = ["tsc"]
4438
}
4539

46-
task copyFavicon(type: Copy) {
47-
dependsOn "webpack"
40+
task eslintPluginTest(type: YarnTask) {
41+
dependsOn "eslintPluginCompile"
4842

49-
from "packages/app/icons/prod-favicon.ico"
50-
into "build/webpack"
51-
rename "prod-favicon.ico", "favicon.ico"
43+
workingDir = file(Paths.get("packages", "eslint-plugin"))
44+
yarnCommand = ["test"]
45+
}
46+
47+
project.tasks.register('eslintPlugin') {
48+
dependsOn 'eslintPluginCompile'
49+
dependsOn 'eslintPluginTest'
50+
}
51+
52+
task lint(type: YarnTask) {
53+
dependsOn "eslintPlugin"
54+
55+
yarnCommand = ["lint"]
56+
}
57+
58+
task prettier(type: YarnTask) {
59+
dependsOn "eslintPlugin"
60+
dependsOn "lint"
61+
62+
yarnCommand = ["prettier:check"]
63+
}
64+
65+
project.tasks.register('runLinters') {
66+
dependsOn "lint"
67+
dependsOn "prettier"
5268
}
5369

5470
task karma(type: YarnTask) {
55-
dependsOn "yarn"
5671
dependsOn "modules"
5772

5873
yarnCommand = ["test"]
@@ -64,10 +79,42 @@ task karma(type: YarnTask) {
6479
}
6580

6681
task functionalTests(type: YarnTask) {
67-
dependsOn "yarn"
6882
dependsOn "modules"
83+
dependsOn "karma"
6984

7085
yarnCommand = ["functional"]
86+
87+
if (project.hasProperty('skipTests')) {
88+
functionalTests.enabled = false
89+
}
90+
}
91+
92+
project.tasks.register('test') {
93+
dependsOn 'karma'
94+
dependsOn 'functionalTests'
95+
}
96+
97+
task webpack(type: YarnTask) {
98+
dependsOn "yarn"
99+
dependsOn "modules"
100+
dependsOn "runLinters"
101+
dependsOn "test"
102+
103+
yarnCommand = ["build"]
104+
environment = [
105+
"NODE_ENV": "production",
106+
"GATE_HOST": "spinnaker-api-prestaging.prod.netflix.net",
107+
"NODE_OPTIONS": "--max_old_space_size=8192",
108+
]
109+
}
110+
webpack.outputs.dir file('build/webpack')
111+
112+
task copyFavicon(type: Copy) {
113+
dependsOn "webpack"
114+
115+
from "packages/app/icons/prod-favicon.ico"
116+
into "build/webpack"
117+
rename "prod-favicon.ico", "favicon.ico"
71118
}
72119

73120
task generateVersionFile {
@@ -83,13 +130,8 @@ task generateVersionFile {
83130
file("version.json").write(buildJson)
84131
}
85132
}
86-
87-
webpack.outputs.dir file('build/webpack')
88-
89133
yarn.dependsOn 'generateVersionFile'
90-
project.tasks.register('test') {
91-
dependsOn 'karma'
92-
}
134+
93135
buildDeb.dependsOn 'copyFavicon'
94136
buildRpm.dependsOn 'webpack'
95137
build.dependsOn 'buildDeb'

version.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"version": "n/a",
3-
"created": 1647951273397
3+
"created": 1648032845852
44
}

0 commit comments

Comments
 (0)