Skip to content

Commit

Permalink
Merge pull request #35 from fountainhead/overdue-fixes
Browse files Browse the repository at this point in the history
Overdue fixes
  • Loading branch information
wms authored Oct 13, 2022
2 parents 4983295 + effb16c commit 297be35
Show file tree
Hide file tree
Showing 13 changed files with 24,921 additions and 14,727 deletions.
11 changes: 4 additions & 7 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"plugins": ["jest", "@typescript-eslint"],
"extends": ["plugin:github/es6"],
"extends": ["plugin:github/recommended"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 9,
"sourceType": "module",
"project": "./tsconfig.json"
},
"rules": {
"i18n-text/no-en": "off",
"eslint-comments/no-use": "off",
"import/no-namespace": "off",
"no-unused-vars": "off",
Expand All @@ -16,13 +17,11 @@
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/array-type": "error",
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/ban-ts-ignore": "error",
"@typescript-eslint/ban-ts-comment": "error",
"camelcase": "off",
"@typescript-eslint/camelcase": "error",
"@typescript-eslint/class-name-casing": "error",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/explicit-function-return-type": ["error", {"allowExpressions": true}],
"@typescript-eslint/func-call-spacing": ["error", "never"],
"@typescript-eslint/generic-type-naming": ["error", "^[A-Z][A-Za-z]*$"],
"@typescript-eslint/no-array-constructor": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "error",
Expand All @@ -32,15 +31,13 @@
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-non-null-assertion": "warn",
"@typescript-eslint/no-object-literal-type-assertion": "error",
"@typescript-eslint/no-unnecessary-qualifier": "error",
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"@typescript-eslint/no-useless-constructor": "error",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/prefer-for-of": "warn",
"@typescript-eslint/prefer-function-type": "warn",
"@typescript-eslint/prefer-includes": "error",
"@typescript-eslint/prefer-interface": "error",
"@typescript-eslint/prefer-string-starts-ends-with": "error",
"@typescript-eslint/promise-function-async": "error",
"@typescript-eslint/require-array-sort-compare": "error",
Expand Down
26 changes: 16 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,27 @@ on: # rebuild any PRs and main branch changes
push:
branches:
- master
- 'releases/*'
- "releases/*"

jobs:
build: # make sure build/ci work properly
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- run: |
npm install
npm run all
- uses: actions/checkout@v3
- run: |
npm ci
npm run all
test: # make sure the action works on a clean machine without building
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: ./
with:
token: ${{ secrets.GITHUB_TOKEN }}
checkName: build
- uses: actions/checkout@v3
- uses: ./
id: wait-for-build
with:
token: ${{ secrets.GITHUB_TOKEN }}
checkName: build
ref: ${{ github.event.pull_request.head.sha || github.sha }}

- name: Fail if build did not succeed
if: steps.wait-for-build.outputs.conclusion != 'success'
run: exit 1
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v16
3 changes: 1 addition & 2 deletions .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": false,
"arrowParens": "avoid",
"parser": "typescript"
"arrowParens": "avoid"
}
21 changes: 10 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ A GitHub Action that allows you to wait for another GitHub check to complete. Th
```yaml
steps:
- name: Wait for build to succeed
uses: fountainhead/action-wait-for-check@v1.0.0
uses: fountainhead/action-wait-for-check@v1.1.0
id: wait-for-build
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -31,44 +31,43 @@ This Action accepts the following configuration parameters via `with:`
- `token`

**Required**

The GitHub token to use for making API requests. Typically, this would be set to `${{ secrets.GITHUB_TOKEN }}`.

- `checkName`

**Required**

The name of the GitHub check to wait for. For example, `build` or `deploy`.

**IMPORTANT**: If the check you're referencing is provided by another GitHub Actions workflow, make sure that you reference the name of a _Job_ within that workflow, and _not_ the name the _Workflow_ itself.

- `ref`

**Default: `github.sha`**

The Git ref of the commit you want to poll for a passing check.

*PROTIP: You may want to use `github.pull_request.head.sha` when working with Pull Requests.*


_PROTIP: You may want to use `github.event.pull_request.head.sha` when working with Pull Requests._

- `repo`

**Default: `github.repo.repo`**

The name of the Repository you want to poll for a passing check.

- `owner`

**Default: `github.repo.owner`**

The name of the Repository's owner you want to poll for a passing check.

- `timeoutSeconds`

**Default: `600`**

The number of seconds to wait for the check to complete. If the check does not complete within this amount of time, this Action will emit a `conclusion` value of `timed_out`.

- `intervalSeconds`

**Default: `10`**
Expand Down
16 changes: 9 additions & 7 deletions __tests__/poll.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import {poll} from '../src/poll'

const client = {
checks: {
listForRef: jest.fn()
rest: {
checks: {
listForRef: jest.fn()
}
}
}

Expand All @@ -19,7 +21,7 @@ const run = () =>
})

test('returns conclusion of completed check', async () => {
client.checks.listForRef.mockResolvedValue({
client.rest.checks.listForRef.mockResolvedValue({
data: {
check_runs: [
{
Expand All @@ -38,7 +40,7 @@ test('returns conclusion of completed check', async () => {
const result = await run()

expect(result).toBe('success')
expect(client.checks.listForRef).toHaveBeenCalledWith({
expect(client.rest.checks.listForRef).toHaveBeenCalledWith({
owner: 'testOrg',
repo: 'testRepo',
ref: 'abcd',
Expand All @@ -47,7 +49,7 @@ test('returns conclusion of completed check', async () => {
})

test('polls until check is completed', async () => {
client.checks.listForRef
client.rest.checks.listForRef
.mockResolvedValueOnce({
data: {
check_runs: [
Expand Down Expand Up @@ -83,11 +85,11 @@ test('polls until check is completed', async () => {
const result = await run()

expect(result).toBe('failure')
expect(client.checks.listForRef).toHaveBeenCalledTimes(3)
expect(client.rest.checks.listForRef).toHaveBeenCalledTimes(3)
})

test(`returns 'timed_out' if exceeding deadline`, async () => {
client.checks.listForRef.mockResolvedValue({
client.rest.checks.listForRef.mockResolvedValue({
data: {
check_runs: [
{
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ inputs:
intervalSeconds:
description: 'The number of seconds to wait before each poll of the GitHub API.'
runs:
using: 'node12'
using: 'node16'
main: 'dist/index.js'
Loading

0 comments on commit 297be35

Please sign in to comment.