Skip to content

Commit cd73667

Browse files
authored
ci: unify GHA build process (#1172)
## 🧰 Changes a few small behind-the-scenes changes to simplify how we build `rdme` for GitHub Actions users — no actual customer impact here. quick breakdown of the changes: - [x] replaces `@rollup/plugin-terser` with `rollup-plugin-esbuild` for minifying our GitHub Actions code. the latter accomplishes basically the same result as the former, but in a tiny fraction of the time. - [x] we previously forked our GHA build process into a development vs. production setup since terser takes so long. since `rollup-plugin-esbuild` adds a negligible amount of time to our build process, there's no need to have two setups. this PR combines them into a single build process. - [x] added a bunch of steps to our CI to further assert that the GitHub Actions build is what we expect. ## 🧬 QA & Testing does CI still pass?
1 parent 4e77b6e commit cd73667

File tree

4 files changed

+79
-67
lines changed

4 files changed

+79
-67
lines changed

.github/workflows/ci.yml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,14 @@ jobs:
7171
#
7272
# This step is not required for syncing your docs to ReadMe!
7373
- name: Rebuild GitHub Action for testing purposes
74-
run: npm ci && npm run build:gha
74+
# We manually invoke `bin/write-gha-pjson.js` here because
75+
# GitHub Actions does not support `pre` scripts for local actions.
76+
run: npm ci && npm run build:gha && bin/write-gha-pjson.js
7577
working-directory: rdme-repo
7678

79+
- name: Run root command
80+
uses: ./rdme-repo/
81+
7782
- name: Run `openapi validate` command
7883
uses: ./rdme-repo/
7984
with:
@@ -98,11 +103,28 @@ jobs:
98103

99104
- name: Assert that previous validation step failed
100105
if: ${{ steps.openapi-validate-fail.outcome == 'failure' }}
101-
run: echo "The validation in the previous step failed as expected."
106+
run: echo "The previous step failed as expected."
102107

103108
- name: Throw error if previous validation step did not fail
104109
if: ${{ steps.openapi-validate-fail.outcome == 'success' }}
105-
run: echo "::error::Expected validation in previous step to fail" && exit 1
110+
run: echo "::error::Expected previous step to fail" && exit 1
111+
112+
# The `help` command is only available in the CLI.
113+
# This step should fail because `help` does not exist in GitHub Actions
114+
- name: Run `help`
115+
uses: ./rdme-repo/
116+
id: help-fail
117+
continue-on-error: true
118+
with:
119+
rdme: help
120+
121+
- name: Assert that previous step failed
122+
if: ${{ steps.help-fail.outcome == 'failure' }}
123+
run: echo "The previous step failed as expected."
124+
125+
- name: Throw error if previous step did not fail
126+
if: ${{ steps.help-fail.outcome == 'success' }}
127+
run: echo "::error::Expected previous step to fail" && exit 1
106128

107129
# this is a test to ensure that the rdme github action can run properly
108130
# the way that our users invoke it

package-lock.json

Lines changed: 49 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@
8282
"@rollup/plugin-json": "^6.0.0",
8383
"@rollup/plugin-node-resolve": "^16.0.0",
8484
"@rollup/plugin-replace": "^6.0.1",
85-
"@rollup/plugin-terser": "^0.4.4",
8685
"@types/configstore": "^6.0.0",
8786
"@types/debug": "^4.1.7",
8887
"@types/js-yaml": "^4.0.5",
@@ -103,6 +102,7 @@
103102
"openapi-types": "^12.1.3",
104103
"prettier": "^3.0.2",
105104
"rollup": "^4.3.0",
105+
"rollup-plugin-esbuild": "^6.2.0",
106106
"tsx": "^4.19.2",
107107
"type-fest": "^4.3.1",
108108
"typescript": "^5.1.6",
@@ -112,7 +112,6 @@
112112
"build": "tsc && cp package.json dist/package.json",
113113
"build:docs": "oclif readme --multi --output-dir documentation/commands --no-aliases",
114114
"build:gha": "npm run build && rollup --config",
115-
"build:gha:prod": "npm run build:gha -- --environment PRODUCTION_BUILD",
116115
"lint": "alex . && knip && npm run lint:ts && npm run prettier && npm run schemas:check",
117116
"lint:ts": "eslint . --ext .js,.ts",
118117
"prebuild": "rm -rf dist/ && rm -f src/package.json && ln package.json src/package.json",
@@ -123,7 +122,7 @@
123122
"schemas:check": "./bin/json-schema-store.js",
124123
"schemas:write": "./bin/json-schema-store.js --update",
125124
"test": "vitest run --coverage",
126-
"version": "npm run build:gha:prod && oclif manifest && npm run build:docs"
125+
"version": "npm run build:gha && oclif manifest && npm run build:docs"
127126
},
128127
"commitlint": {
129128
"extends": [

rollup.config.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1+
// @ts-check
12
import commonjs from '@rollup/plugin-commonjs';
23
import json from '@rollup/plugin-json';
34
import { nodeResolve } from '@rollup/plugin-node-resolve';
45
import replace from '@rollup/plugin-replace';
5-
import terser from '@rollup/plugin-terser';
66
import { defineConfig } from 'rollup';
7-
8-
const isProductionBuild = process.env.PRODUCTION_BUILD === 'true';
7+
import { minify } from 'rollup-plugin-esbuild';
98

109
const basePlugins = [
1110
commonjs(),
@@ -16,14 +15,9 @@ const basePlugins = [
1615
exportConditions: ['node'],
1716
preferBuiltins: true,
1817
}),
18+
minify(),
1919
];
2020

21-
// only minify when doing a "production" build (i.e., for a release)
22-
// it takes a lot longer!
23-
if (isProductionBuild) {
24-
basePlugins.push(terser());
25-
}
26-
2721
export default defineConfig([
2822
{
2923
input: 'bin/run.js',

0 commit comments

Comments
 (0)