Part 1: Logging Improvements (#1022)

* Part 1 of Logging Improvements

* Update util.test.ts

* Update util.test.ts

* Update util.test.ts

* Update util.test.ts

* Adjustments to tests

* Update util.test.ts

* Update util.ts
This commit is contained in:
James Ives 2022-01-31 08:08:23 -05:00 committed by GitHub
parent cdd72ba2c4
commit 91d4e8f962
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 55 additions and 35 deletions

View File

@ -1,17 +1,15 @@
// https://github.com/microsoft/vscode-dev-containers/tree/master/containers/typescript-node // https://github.com/microsoft/vscode-dev-containers/tree/master/containers/typescript-node
{ {
"name": "Node.js & TypeScript", "name": "Node.js & TypeScript",
"build": { "build": {
"dockerfile": "Dockerfile", "dockerfile": "Dockerfile",
"args": { "args": {
"VARIANT": "14" "VARIANT": "14"
} }
}, },
"settings": { "settings": {
"terminal.integrated.shell.linux": "/bin/bash" "terminal.integrated.shell.linux": "/bin/bash"
}, },
"extensions": [ "extensions": ["dbaeumer.vscode-eslint"],
"dbaeumer.vscode-eslint" "remoteUser": "node"
],
"remoteUser": "node"
} }

View File

@ -218,7 +218,7 @@ jobs:
integration-container, integration-container,
integration-ssh, integration-ssh,
integration-ssh-third-party-client, integration-ssh-third-party-client,
integration-env, integration-env
] ]
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:

View File

@ -18,7 +18,7 @@ jobs:
file: 'README.md' file: 'README.md'
template: '<a href="https://github.com/{{{ login }}}"><img src="https://github.com/{{{ login }}}.png" width="50px" alt="{{{ login }}}" /></a>&nbsp;&nbsp;' template: '<a href="https://github.com/{{{ login }}}"><img src="https://github.com/{{{ login }}}.png" width="50px" alt="{{{ login }}}" /></a>&nbsp;&nbsp;'
maximum: 9999 maximum: 9999
- name: Generate Sponsors 💖 - name: Generate Sponsors 💖
uses: JamesIves/github-sponsors-readme-action@v1.0.8 uses: JamesIves/github-sponsors-readme-action@v1.0.8
with: with:
@ -28,7 +28,6 @@ jobs:
template: '<a href="https://github.com/{{{ login }}}"><img src="https://github.com/{{{ login }}}.png" width="80px" alt="{{{ login }}}" /></a>&nbsp;&nbsp;' template: '<a href="https://github.com/{{{ login }}}"><img src="https://github.com/{{{ login }}}.png" width="80px" alt="{{{ login }}}" /></a>&nbsp;&nbsp;'
marker: 'premium' marker: 'premium'
- name: Deploy to GitHub Pages - name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4.2.2 uses: JamesIves/github-pages-deploy-action@v4.2.2
with: with:

View File

@ -3,7 +3,7 @@ name: Update Major Version Tag
on: on:
push: push:
tags: tags:
- "v*" - 'v*'
jobs: jobs:
update-majorver: update-majorver:

View File

@ -1 +1,2 @@
process.env.ACTIONS_STEP_DEBUG = 'false' process.env.ACTIONS_STEP_DEBUG = 'false'
process.env.RUNNER_OS = 'Windows'

View File

@ -3,6 +3,7 @@ process.env['INPUT_FOLDER'] = 'build'
process.env['GITHUB_SHA'] = '123' process.env['GITHUB_SHA'] = '123'
process.env['INPUT_DEBUG'] = 'debug' process.env['INPUT_DEBUG'] = 'debug'
process.env['GITHUB_REF_NAME'] = 'test' process.env['GITHUB_REF_NAME'] = 'test'
process.env['RUNNER_OS'] = 'Linux'
import '../src/main' import '../src/main'
import {action, TestFlag} from '../src/constants' import {action, TestFlag} from '../src/constants'
@ -27,7 +28,8 @@ jest.mock('@actions/core', () => ({
setOutput: jest.fn(), setOutput: jest.fn(),
exportVariable: jest.fn(), exportVariable: jest.fn(),
isDebug: jest.fn(), isDebug: jest.fn(),
info: jest.fn() info: jest.fn(),
notice: jest.fn()
})) }))
describe('main', () => { describe('main', () => {

View File

@ -224,7 +224,7 @@ describe('util', () => {
checkParameters(action) checkParameters(action)
} catch (e) { } catch (e) {
expect(e instanceof Error && e.message).toMatch( expect(e instanceof Error && e.message).toMatch(
'No deployment token/method was provided. You must provide the action with either a Personal Access Token or the GitHub Token secret in order to deploy. If you wish to use an ssh deploy token then you must set SSH to true.' 'No deployment token/method was provided. You must provide the action with either a Personal Access Token or the GitHub Token secret in order to deploy. For more details on how to use an ssh deploy key please refer to the documentation.'
) )
} }
}) })
@ -244,7 +244,7 @@ describe('util', () => {
checkParameters(action) checkParameters(action)
} catch (e) { } catch (e) {
expect(e instanceof Error && e.message).toMatch( expect(e instanceof Error && e.message).toMatch(
'No deployment token/method was provided. You must provide the action with either a Personal Access Token or the GitHub Token secret in order to deploy. If you wish to use an ssh deploy token then you must set SSH to true.' 'No deployment token/method was provided. You must provide the action with either a Personal Access Token or the GitHub Token secret in order to deploy. For more details on how to use an ssh deploy key please refer to the documentation.'
) )
} }
}) })

View File

@ -1,4 +1,4 @@
import {exportVariable, info, setFailed, setOutput} from '@actions/core' import {exportVariable, info, notice, setFailed, setOutput} from '@actions/core'
import {ActionInterface, NodeActionInterface, Status} from './constants' import {ActionInterface, NodeActionInterface, Status} from './constants'
import {deploy, init} from './git' import {deploy, init} from './git'
import {configureSSH} from './ssh' import {configureSSH} from './ssh'
@ -21,8 +21,25 @@ export default async function run(
try { try {
info(` info(`
GitHub Pages Deploy Action 🚀
`)
info(`
💖 Support: https://github.com/sponsors/JamesIves 💖 Support: https://github.com/sponsors/JamesIves
📣 Maintained by James Ives: https://jamesiv.es 📣 Maintained by James Ives: https://jamesiv.es
@ -53,17 +70,19 @@ export default async function run(
status = await deploy(settings) status = await deploy(settings)
} catch (error) { } catch (error) {
status = Status.FAILED status = Status.FAILED
setFailed(extractErrorMessage(error)) setFailed(extractErrorMessage(error))
} finally { } finally {
info( const terminationMessage = `${
`${ status === Status.FAILED
status === Status.FAILED ? 'Deployment failed! ❌'
? 'Deployment failed! ❌' : status === Status.SUCCESS
: status === Status.SUCCESS ? 'Completed deployment successfully! ✅'
? 'Completed deployment successfully! ✅' : 'There is nothing to commit. Exiting early… 📭'
: 'There is nothing to commit. Exiting early… 📭' }`
}`
) info(terminationMessage)
notice(terminationMessage)
exportVariable('deployment_status', status) exportVariable('deployment_status', status)
setOutput('deployment-status', status) setOutput('deployment-status', status)

View File

@ -1,4 +1,4 @@
import {isDebug, info} from '@actions/core' import {isDebug, warning} from '@actions/core'
import {existsSync} from 'fs' import {existsSync} from 'fs'
import path from 'path' import path from 'path'
import { import {
@ -47,6 +47,7 @@ const hasRequiredParameters = <K extends keyof RequiredActionParameters>(
const nonNullParams = params.filter( const nonNullParams = params.filter(
param => !isNullOrUndefined(action[param]) param => !isNullOrUndefined(action[param])
) )
return Boolean(nonNullParams.length) return Boolean(nonNullParams.length)
} }
@ -54,7 +55,7 @@ const hasRequiredParameters = <K extends keyof RequiredActionParameters>(
export const checkParameters = (action: ActionInterface): void => { export const checkParameters = (action: ActionInterface): void => {
if (!hasRequiredParameters(action, ['token', 'sshKey'])) { if (!hasRequiredParameters(action, ['token', 'sshKey'])) {
throw new Error( throw new Error(
'No deployment token/method was provided. You must provide the action with either a Personal Access Token or the GitHub Token secret in order to deploy. If you wish to use an ssh deploy token then you must set SSH to true.' 'No deployment token/method was provided. You must provide the action with either a Personal Access Token or the GitHub Token secret in order to deploy. For more details on how to use an ssh deploy key please refer to the documentation.'
) )
} }
@ -77,7 +78,7 @@ export const checkParameters = (action: ActionInterface): void => {
process.env.RUNNER_OS as OperatingSystems process.env.RUNNER_OS as OperatingSystems
) )
) { ) {
info( warning(
`The operating system you're using is not supported and results may be varied. Please refer to the documentation for more details. ❗` `The operating system you're using is not supported and results may be varied. Please refer to the documentation for more details. ❗`
) )
} }