Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: oclif mess around #1067

Merged
merged 29 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c9e2b1c
feat: first attempt at prebuilt nodejs files
kanadgupta Nov 16, 2024
97e0121
chore: bring in dep changes, rollup config
kanadgupta Nov 16, 2024
8779c60
chore: lockfile fixes?
kanadgupta Nov 16, 2024
1233e1b
fix: knip
kanadgupta Nov 16, 2024
a99cdaf
test: some vitest config
kanadgupta Nov 16, 2024
ec30bac
fix: use string-argv to parse args
kanadgupta Nov 16, 2024
4ba1a58
fix: whoops how did that get in there
kanadgupta Nov 16, 2024
30bf267
Merge branch 'oclif-explicit' into oclif-gha-test
kanadgupta Nov 16, 2024
87fa119
Merge branch 'oclif-explicit' into oclif-gha-test
kanadgupta Nov 16, 2024
ee7aeef
chore: update this?
kanadgupta Nov 16, 2024
d76642d
Merge branch 'oclif-explicit' into oclif-gha-test
kanadgupta Nov 16, 2024
9602348
Merge branch 'oclif-explicit' into oclif-gha-test
kanadgupta Nov 16, 2024
ad3b864
ci: split out rollup configs into dev/prod
kanadgupta Nov 16, 2024
38822c4
fix: oops build deps first
kanadgupta Nov 16, 2024
c27e34a
chore: rename directory
kanadgupta Nov 16, 2024
09ae653
chore: rename files
kanadgupta Nov 16, 2024
702cfbe
fix: whoops also update these filepaths
kanadgupta Nov 16, 2024
16691d0
chore: can we remove even more properties?
kanadgupta Nov 16, 2024
a3e66ad
chore: whoops smol dist
kanadgupta Nov 16, 2024
850488c
Merge branch 'oclif-explicit' into oclif-gha-test
kanadgupta Nov 16, 2024
d01d76f
chore: yet another knip fix
kanadgupta Nov 16, 2024
9478065
Merge branch 'oclif-explicit' into oclif-gha-test
kanadgupta Nov 17, 2024
71ef5b7
refactor: merge bin/run files
kanadgupta Nov 17, 2024
09e4d4a
chore: rebuild dists
kanadgupta Nov 17, 2024
75b8639
chore: update lockfile
kanadgupta Nov 17, 2024
05d61b3
Merge branch 'oclif-explicit' into oclif-gha-test
kanadgupta Nov 17, 2024
703f6f8
Merge branch 'oclif-explicit' into oclif-gha-test
kanadgupta Nov 18, 2024
cf0d4a2
chore: delete and gitignore dist-gha/package.json
kanadgupta Nov 18, 2024
e66a8d1
feat: attempt to use pre-run hook to create package.json
kanadgupta Nov 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
coverage/
dist/
dist-gha/
exe/
15 changes: 4 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,10 @@ jobs:
path: oas-examples-repo
repository: readmeio/oas-examples

# For every GitHub Action release, we deploy our Docker images
# to the GitHub Container Registry for performance reasons.
# Instead of testing against the pre-built image, we can build
# an image from the currently checked-out repo contents by doing a
# li'l update in the action.yml file to point to the current Dockerfile.
- name: Replace Docker image value in action.yml
uses: jacobtomlinson/gha-find-replace@v3
with:
find: 'image:.*'
replace: "image: 'Dockerfile'"
include: rdme-repo/action.yml
# TODO: write a smol explainer comment
- name: Rebuild GitHub Action for testing purposes
run: 'npm ci && npm run build:gha'
working-directory: rdme-repo

- name: Run `openapi:validate` command
uses: ./rdme-repo/
Expand Down
14 changes: 3 additions & 11 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,9 @@ jobs:
regex: false
include: documentation/*

# For every GitHub Action release, we deploy our Docker images
# to the GitHub Container Registry for performance reasons.
# Instead of testing against the pre-built image, we can build
# an image from the currently checked-out repo contents by doing a
# li'l update in the action.yml file to point to the current Dockerfile.
- name: Replace Docker image value in action.yml
uses: jacobtomlinson/gha-find-replace@v3
with:
find: 'image:.*'
replace: "image: 'Dockerfile'"
include: action.yml
# TODO: write a smol explainer comment
- name: Rebuild GitHub Action for testing purposes
run: 'npm ci && npm run build:gha'

# And finally, with our updated documentation,
# we run the `rdme` GitHub Action to sync the Markdown file
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ node_modules/
tmp/

# required for building with TS
dist-gha/package.json
src/package.json
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ __tests__/__fixtures__/invalid-json/yikes.json
CHANGELOG.md
coverage/
dist/
dist-gha/
exe/
8 changes: 3 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ outputs:
rdme:
description: The rdme command result output
runs:
using: docker
image: docker://ghcr.io/readmeio/rdme:9.0.0-next.19
args:
- docker-gha
- ${{ inputs.rdme }}
using: node20
pre: bin/write-gha-pjson.js
main: dist-gha/run.cjs
8 changes: 7 additions & 1 deletion bin/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@
// ^ we need this env variable above to hide the ExperimentalWarnings
// source: https://github.com/nodejs/node/issues/10802#issuecomment-573376999

import stringArgv from 'string-argv';

async function main() {
const { execute } = await import('@oclif/core');
await execute({ dir: import.meta.url }).then(msg => {
const opts = { dir: import.meta.url };
if (process.env.INPUT_RDME) {
opts.args = stringArgv(process.env.INPUT_RDME);
}
await execute(opts).then(msg => {
if (msg) {
// eslint-disable-next-line no-console
console.log(msg);
Expand Down
35 changes: 35 additions & 0 deletions bin/write-gha-pjson.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#! /usr/bin/env node
// @ts-check

import fs from 'node:fs';
import path from 'node:path';

const newTarget = './cmds.js';

/**
* We need to duplicate the `package.json` file (with a few modifications) from the root of the project to the
* `dist-gha` directory, so that the GitHub Actions-flavored `oclif` configuration can find it.
*/
function writeGitHubActionsPackageJson() {
const current = JSON.parse(
fs.readFileSync(path.resolve(import.meta.dirname, '../package.json'), { encoding: 'utf-8' }),
);

current.private = true;

// set the correct targets for GitHub Actions
current.oclif.commands.target = newTarget;
Object.values(current.oclif.hooks).forEach(hook => {
// eslint-disable-next-line no-param-reassign
hook.target = newTarget;
});

// remove properties that are only applicable in a CLI context
delete current.oclif.helpClass;
delete current.oclif.plugins;

// write the new package.json file
fs.writeFileSync(path.resolve(import.meta.dirname, '../dist-gha/package.json'), JSON.stringify(current, null, 2));
}

writeGitHubActionsPackageJson();
93 changes: 93 additions & 0 deletions dist-gha/cmds.js

Large diffs are not rendered by default.

61 changes: 61 additions & 0 deletions dist-gha/run.cjs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions knip.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { KnipConfig } from 'knip';

const config: KnipConfig = {
entry: ['src/index.ts', 'src/lib/help.ts'],
ignore: ['bin/*.js'],
entry: ['src/index.ts', 'src/lib/help.ts', 'bin/*.js'],
ignore: ['dist-gha/**'],
ignoreBinaries: ['semantic-release'],
ignoreDependencies: ['oclif'],
};
Expand Down
Loading
Loading