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

feat(action): introduce fork action #2

Merged
merged 30 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
efc985f
feat(api): dispatch workflow with listing jobs
clearloop Dec 20, 2023
806fb6c
feat(api): check related apis
clearloop Dec 20, 2023
34937ee
feat(api): introduce fork api
clearloop Dec 20, 2023
55ae0d6
feat(action): provide main function
clearloop Dec 20, 2023
1129aec
chore(config): customized config files
clearloop Dec 20, 2023
2f06c00
fix(ci): use == instead of ===
clearloop Dec 20, 2023
f4af8e7
ci(linter): disable jest
clearloop Dec 20, 2023
9cc3a40
chore(deps): remove jest related stuffs
clearloop Dec 20, 2023
3471618
ci(cancel): remove cancel-in-progress
clearloop Dec 20, 2023
4fd5888
chore(github): import * from github deps
clearloop Dec 20, 2023
69b23dc
ci(linter): move resolver to linter
clearloop Dec 20, 2023
0709557
ci(linter): formatting
clearloop Dec 20, 2023
b701123
ci(action): default value for inputs
clearloop Dec 20, 2023
0e1d84d
ci(ci): clean permissions
clearloop Dec 20, 2023
c3d9d2d
chore(api): more logs for the progress
clearloop Dec 20, 2023
6d6d5f7
ci(ci): correct the job name in inputs
clearloop Dec 20, 2023
b1c5b90
chore(api): returns jobs on forking
clearloop Dec 20, 2023
7acf21e
fix(api): update checks with matched check run id
clearloop Dec 20, 2023
7d63222
ci(test): dispatch testing
clearloop Dec 20, 2023
689dabe
ci(ci): formatting
clearloop Dec 20, 2023
677bbec
ci(ci): format JSON input
clearloop Dec 20, 2023
4cccbc6
chore(api): error handling for fetching workflow runs
clearloop Dec 21, 2023
d7f8d9a
ci(dispatch): correct runner
clearloop Dec 21, 2023
f0e31dc
chore(api): handle not found again
clearloop Dec 21, 2023
acff458
fix(api): unpack ref from ref
clearloop Dec 21, 2023
8309a25
chore(api): get back error handling for latestRun
clearloop Dec 21, 2023
9711832
ci(dispatch): double check if the workflow file can be found by github
clearloop Dec 21, 2023
9b4189b
chore(api): padding job prefix
clearloop Dec 21, 2023
d5fb3f5
chore(api): unpack PR number as string
clearloop Dec 21, 2023
8d78551
ci(ci): fix the quotes
clearloop Dec 21, 2023
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
9 changes: 5 additions & 4 deletions .github/linters/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
settings:
import/resolver:
- typescript

env:
node: true
es6: true
jest: true

globals:
Atomics: readonly
Expand All @@ -24,15 +27,13 @@ parserOptions:
- './tsconfig.json'

plugins:
- jest
- '@typescript-eslint'

extends:
- eslint:recommended
- plugin:@typescript-eslint/eslint-recommended
- plugin:@typescript-eslint/recommended
- plugin:github/recommended
- plugin:jest/recommended

rules:
{
Expand Down Expand Up @@ -76,7 +77,7 @@ rules:
'@typescript-eslint/promise-function-async': 'error',
'@typescript-eslint/require-array-sort-compare': 'error',
'@typescript-eslint/restrict-plus-operands': 'error',
'@typescript-eslint/semi': ['error', 'never'],
'@typescript-eslint/semi': ['error', 'always'],
'@typescript-eslint/space-before-function-paren': 'off',
'@typescript-eslint/type-annotation-spacing': 'error',
'@typescript-eslint/unbound-method': 'error'
Expand Down
4 changes: 2 additions & 2 deletions .github/linters/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{

Check warning on line 1 in .github/linters/tsconfig.json

View workflow job for this annotation

GitHub Actions / Lint Codebase

File ignored by default.
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "../../tsconfig.json",
"compilerOptions": {
"noEmit": true
},
"include": ["../../__tests__/**/*", "../../src/**/*"],
"exclude": ["../../dist", "../../node_modules", "../../coverage", "*.json"]
"include": ["../../src/**/*"],
"exclude": ["../../dist", "../../node_modules", "*.json"]
}
13 changes: 8 additions & 5 deletions .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ on:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:

permissions:
contents: read

jobs:
check-dist:
name: Check dist/
name: Check dist
runs-on: ubuntu-latest

steps:
Expand All @@ -33,18 +36,18 @@ jobs:
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm
cache: yarn

- name: Install Dependencies
id: install
run: npm ci
run: yarn install --frozen-lockfile

- name: Build dist/ Directory
id: build
run: npm run bundle
run: yarn bundle

# This will fail the workflow if the PR wasn't created by Dependabot.
- name: Compare Directories
- name: Diff
id: diff
run: |
if [ "$(git diff --ignore-space-at-eol --text dist/ | wc -l)" -gt "0" ]; then
Expand Down
63 changes: 39 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
name: Continuous Integration
name: CI

on:
pull_request:
branches:
- main
push:
branches:
- main

permissions:
contents: read

jobs:
test-typescript:
name: TypeScript Tests
Expand All @@ -26,37 +25,53 @@ jobs:
node-version-file: .node-version
cache: npm

- name: Install Dependencies
id: npm-ci
run: npm ci
- name: Install current dependencies
run: yarn install --frozen-lockfile

- name: Check Format
id: npm-format-check
run: npm run format:check
run: yarn format:check

- name: Lint
id: npm-lint
run: npm run lint

- name: Test
id: npm-ci-test
run: npm run ci-test
run: yarn lint

test-action:
name: GitHub Actions Test
fork-running:
name: fork-running
runs-on: ubuntu-latest

if: github.event_name == 'pull_request'
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4

- name: Test Local Action
id: test-action
- name: Fork running workflow
uses: ./
with:
milliseconds: 2000
token: ${{ secrets.GITHUB_TOKEN }}
workflow_id: '.github/workflows/check-dist.yml'
jobs: '["Check dist"]'
head_sha: ${{ github.event.pull_request.head.sha }}
repo: 'gear-tech/fork-action'
ref: ${{ github.head_ref || github.ref_name }}

- name: Print Output
id: output
run: echo "${{ steps.test-action.outputs.time }}"
dispatch-and-fork:
name: dispatch-and-fork
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4

- name: Dispatch and Fork
uses: ./
with:
token: ${{ secrets.GITHUB_TOKEN }}
workflow_id: '.github/workflows/dispatch.yml'
jobs: '["dispatch"]'
head_sha: ${{ github.event.pull_request.head.sha }}
repo: 'gear-tech/fork-action'
ref: ${{ github.head_ref || github.ref_name }}
prefix: 'build'
inputs:
'{ "title": "${{ github.event.pull_request.title }}", "number": "${{
github.event.number }}" }'
20 changes: 20 additions & 0 deletions .github/workflows/dispatch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Dispatch

on:
workflow_dispatch:
inputs:
title:
type: string
description: 'Pull request title that triggers this workflow.'
number:
type: string
description: 'Pull request number that triggers this workflow'

run-name: ${{ inputs.title }} ( ${{ format('#{0}', inputs.number) }} )

jobs:
dispatch:
runs-on: ubuntu-latest
steps:
- name: Dummy
run: echo "Hello, world"
7 changes: 2 additions & 5 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,15 @@ jobs:
uses: actions/checkout@v4

- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: npm
cache: yarn

- name: Install Dependencies
id: install
run: npm ci
run: yarn install --frozen-lockfile

- name: Lint Codebase
id: super-linter
uses: super-linter/super-linter/slim@v5
env:
DEFAULT_BRANCH: main
Expand Down
2 changes: 1 addition & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{

Check warning on line 1 in .prettierrc.json

View workflow job for this annotation

GitHub Actions / Lint Codebase

File ignored by default.
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": false,
"semi": true,
"singleQuote": true,
"quoteProps": "as-needed",
"jsxSingleQuote": false,
Expand Down
17 changes: 0 additions & 17 deletions __tests__/index.test.ts

This file was deleted.

89 changes: 0 additions & 89 deletions __tests__/main.test.ts

This file was deleted.

25 changes: 0 additions & 25 deletions __tests__/wait.test.ts

This file was deleted.

Loading