-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add wrapper for GitHub Actions (#437)
* feat: add initial github action config * ci: add gh action test * test: refactor test to check for exact UA match * feat: dynamically set user agent based on env * chore: temporarily skip test suite Our test bed is a bit broken right now and I should fix this up, but I just want to see how the GitHub Action test runs for the time being 😬 * chore: silence npm i logs * ci: restore tests, move action test to separate workflow file * Update action.yml * chore: update param names, job names * fix: attempt to get npm install working properly * chore: update loglevel * chore: ok updating log level AGAIN Once we add a debug option, I'll also update this line to reflect that! * chore: set working directory instead Docs: https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runsstepsworking-directory * test: attempt to get CI working again * test: how about this? * refactor: consolidate user-agent logic * refactor: move path to `working_directory` This way our logs look a little cleaner! * chore: typo * chore: remove unnecessary quotes * chore: oops * chore: does this look any cleaner? * fix: try this * revert: eh nvm * chore: removing quotes in one last place * revert: move this back So interesting thing I discovered in this test run: https://github.com/kanadgupta/metrotransit-nextrip-oas/runs/5163683403?check_suite_focus=true#step:3:18 Even though this will look a bit messier in the user's action logs, this is the only way to ensure that the command runs in the user's GitHub repo :sad: * ci: update test workflow to test it with another repo * ci: will this work? * ci: add a token that hopefully works * chore: consolidate CI * refactor: consolidate nock logic * chore: small formatting tweaks * ci: add upload step * fix: see if chalk prints colors nicely with this env var * chore: update workflow docs a bit
- Loading branch information
1 parent
9cbcaef
commit f0b9d11
Showing
6 changed files
with
107 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ on: [push] | |
|
||
jobs: | ||
build: | ||
name: Test Suite | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
|
@@ -22,3 +23,30 @@ jobs: | |
|
||
- name: Run tests | ||
run: npm test | ||
|
||
action: | ||
name: GitHub Action Dry Run | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout GitHub Action | ||
uses: actions/[email protected] | ||
with: | ||
path: rdme-repo | ||
|
||
- name: Checkout external repo containing OpenAPI file | ||
uses: actions/[email protected] | ||
with: | ||
path: oas-examples-repo | ||
repository: readmeio/oas-examples | ||
token: ${{ secrets.OAS_EXAMPLES_READ }} | ||
|
||
- name: Run `validate` command | ||
uses: ./rdme-repo/ | ||
with: | ||
rdme: validate oas-examples-repo/3.1/json/petstore.json | ||
|
||
# Docs: https://rdme-test.readme.io | ||
- name: Run `openapi` command | ||
uses: ./rdme-repo/ | ||
with: | ||
rdme: openapi oas-examples-repo/3.1/json/petstore.json --key=${{ secrets.RDME_TEST_PROJECT_API_KEY }} --id=${{ secrets.RDME_TEST_PROJECT_API_SETTING }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,12 @@ | ||
const nock = require('nock'); | ||
const config = require('config'); | ||
const pkg = require('../package.json'); | ||
|
||
const userAgent = `rdme/${pkg.version}`; | ||
const nock = require('nock'); | ||
const { getUserAgent } = require('../src/lib/fetch'); | ||
|
||
module.exports = function () { | ||
module.exports = function (reqHeaders = {}) { | ||
return nock(config.get('host'), { | ||
reqheaders: { | ||
'User-Agent': userAgent, | ||
'User-Agent': getUserAgent(), | ||
...reqHeaders, | ||
}, | ||
}); | ||
}; | ||
|
||
module.exports.userAgent = userAgent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: rdme | ||
author: ReadMe | ||
branding: | ||
color: blue | ||
icon: book-open | ||
description: Update your ReadMe developer hubs in a CI environment. | ||
inputs: | ||
rdme: | ||
description: Command to pass into rdme | ||
required: true | ||
runs: | ||
using: composite | ||
steps: | ||
# This is so we can guarantee a version of npm that supports lockfile@2 | ||
- name: setup node | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 16 | ||
# When we add debug support, we should make this a conditional step, see RM-3545 | ||
- name: Install rdme deps | ||
run: npm install --production --silent | ||
shell: bash | ||
working-directory: ${{ github.action_path }} | ||
- name: Execute rdme command | ||
run: ${{ github.action_path }}/bin/rdme ${{ inputs.rdme }} | ||
shell: bash | ||
env: | ||
FORCE_COLOR: '1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters