Skip to content
Permalink
Browse files
First draft
  • Loading branch information
LouisBrunner committed Feb 29, 2020
1 parent b8b3df6 commit d3d705842bf1b5a37ab2362b9cedf5959cdd5db9
Showing 13 changed files with 479 additions and 55 deletions.
@@ -14,6 +14,7 @@
"project": "./tsconfig.eslint.json"
},
"rules": {
"@typescript-eslint/camelcase": ["off"]
},
"env": {
"node": true,
@@ -4,6 +4,7 @@ on: # rebuild any PRs and main branch changes
push:
branches:
- master
- 'feature/*'
- 'releases/*'

jobs:
@@ -15,14 +16,3 @@ jobs:
- run: |
npm install
npm run all
# make sure the action works on a clean machines without building
test1:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: ./
with:
token: ${{ secrets.GITHUB_TOKEN }}

# TODO: add more (race conditions, failures, etc)
@@ -0,0 +1,252 @@
name: "examples"
on: [push]

jobs:
# make sure the action works on a clean machines without building

## Basic
test_basic_success:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: ./
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Test Basic Success
conclusion: success

test_basic_success_with_output:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: ./
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Test Basic Success (Implicit)
conclusion: success
output:
summary: Test was a success
text_description: |
This is a text description of the annotations and images
With more stuff
And more
test_basic_failure:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: ./
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Test Basic Failure
conclusion: failure

# Other codes
test_basic_neutral:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: ./
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Test 1 = Neutral
conclusion: neutral

test_basic_cancelled:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: ./
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Test Basic Cancelled
conclusion: cancelled

test_basic_timed_out:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: ./
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Test Basic Timed Out
conclusion: timed_out

test_basic_action_required:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: ./
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Test Basic Action Required
conclusion: action_required

## Based on command
test_with_annotation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: ./
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Test Advanced With Output
conclusion: success

## With annotations
test_with_annotations:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: ./
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Test With Annotations
conclusion: success
output: # output.summary is required with annotations!
summary: Some warnings in README.md
annotations:
- path: README.md
annotation_level: warning
title: Spell Checker
message: Check your spelling for 'banaas'.
raw_details: Do you mean 'bananas' or 'banana'?
start_line: 1
end_line: 2

test_with_annotations_from_run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- id: annotations
run: |
echo ::set-output name=value::{"path":"README.md","start_line":1,"end_line":2,"message":"Check your spelling for 'banaas'.","annotation_level":"warning"}
- uses: ./
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Test With Annotations From Run
conclusion: success
output: # output.summary is required with annotations!
summary: Some warnings in README.md
annotations: ${{ steps.annotations.outputs.value }}

## With images
test_with_images:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: ./
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Test With Images
conclusion: success
output: # output.summary is required with images!
summary: Some cool pics
images:
- alt: Cool pic
image_url: https://via.placeholder.com/150
caption: Cool description

test_with_images_from_run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- id: images
run: |
echo ::set-output name=value::{"alt":"Cool pic","image_url":"https://via.placeholder.com/150","caption":"Cool description"}
- uses: ./
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Test With Images From Run
conclusion: success
output: # output.summary is required with images!
summary: Some warnings in README.md
images: ${{ steps.images.outputs.value }}

## With actions
# TODO: HOW DO WE SET THE WEBHOOK!
test_with_actions:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: ./
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Test With Actions
conclusion: success
actions:
- label: Click Me
description: Click me to get free RAM
identifier: sent_to_webhook

test_with_actions_from_run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- id: actions
run: |
echo ::set-output name=value::{"label":"Click Me","description":"Click me to get free RAM","identifier":"sent_to_webhook"}
- uses: ./
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Test With Actions From Run
conclusion: success
# output.summary is required with actions!
output:
summary: Some warnings in README.md
actions: ${{ steps.actions.outputs.value }}

## With init
test_with_init:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: ./
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Test With Init
status: in_progress
- run: sleep 30
- uses: ./
with:
token: ${{ secrets.GITHUB_TOKEN }}
status: completed
conclusion: failure

test_with_init_implicit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: ./
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Test With Init (Implicit)
status: in_progress
- run: sleep 30
- uses: ./
with:
token: ${{ secrets.GITHUB_TOKEN }}
conclusion: failure

## Based on job
test_based_job_success:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: ./
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Test Based On Job (Success)
conclusion: ${{ job }}

test_based_job_failure:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- run: false
- uses: ./
if: always()
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Test Based On Job (Failure)
conclusion: ${{ job }}
@@ -1,8 +1,8 @@
{
"printWidth": 80,
"printWidth": 120,
"tabWidth": 2,
"useTabs": false,
"semi": false,
"semi": true,
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": false,
@@ -1,15 +1,15 @@
import * as process from 'process'
import * as cp from 'child_process'
import * as path from 'path'
import * as process from 'process';
import * as cp from 'child_process';
import * as path from 'path';

// shows how the runner will run a javascript action with env / stdout protocol
test('test runs', () => {
process.env['TOKEN'] = 'ABC'
const ip = path.join(__dirname, '..', 'lib', 'main.js')
process.env['TOKEN'] = 'ABC';
const ip = path.join(__dirname, '..', 'lib', 'main.js');
const options: cp.ExecSyncOptions = {
env: process.env,
}
console.log(cp.execSync(`node ${ip}`, options).toString())
})
};
console.log(cp.execSync(`node ${ip}`, options).toString());
});

// TODO: add more
@@ -4,6 +4,29 @@ author: 'Louis Brunner'
inputs:
token:
description: 'your GITHUB_TOKEN'
required: true
name:
description: 'the name of your check'
required: true
conclusion:
description: 'the conclusion of your check'
required: true
status:
description: 'the status of your check'
required: false
default: completed
output:
description: 'the output of your check'
required: false
annotations:
description: 'the annotations of your check'
required: false
images:
description: 'the images of your check'
required: false
actions:
description: 'the actions of your check'
required: false
runs:
using: 'node12'
main: 'dist/index.js'

0 comments on commit d3d7058

Please sign in to comment.