Skip to content

Commit

Permalink
Major Rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
sammcj committed Feb 13, 2024
1 parent 31053a2 commit 2a8d748
Show file tree
Hide file tree
Showing 27 changed files with 5,012 additions and 2,413 deletions.
35 changes: 29 additions & 6 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
module.exports = {
env: {
browser: true,
commonjs: true,
es2021: true,
},
plugins: ['deprecation', 'import', 'prettier', 'import'],
extends: ['eslint:recommended', 'prettier', 'plugin:import/recommended'],
plugins: ['import', 'prettier'],
extends: ['plugin:prettier/recommended', 'eslint:recommended'],
overrides: [
{
env: {
node: true,
},
files: ['.eslintrc.{js,cjs}'],
parserOptions: {
sourceType: 'script',
ecmaVersion: 'latest',
},
},
],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'commonjs',
sourceType: 'module',
},
rules: {
quotes: ['error', 'single', { avoidEscape: true }],
Expand All @@ -24,14 +36,25 @@ module.exports = {
'space-before-blocks': 'error',
curly: ['error', 'multi-line', 'consistent'],
'no-bitwise': ['error'],
'no-console': 0,
'no-trailing-spaces': ['error'],
'no-duplicate-imports': ['error'],
'no-shadow': 'off',
'no-use-before-define': 'off',
'import/order': 'error',
'prettier/prettier': 'error',
'max-classes-per-file': ['error', 3],
'no-underscore-dangle': 'off',
'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
indent: ['error', 2],
'max-params': ['error', 5],
},
ignorePatterns: [
'!**/*.eslintrc.js*',
'!**/*.prettierrc.js*',
'**/node_modules/**',
'**/dist/**',
'**/build/**',
'**/coverage/**',
'**/cdk.out/**',
'jest.setup.ts',
],
};
63 changes: 0 additions & 63 deletions .eslintrc.js

This file was deleted.

43 changes: 0 additions & 43 deletions .github/workflows/bump-version.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/delete-disabled-workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
timeout-minutes: 15
if: inputs.delete-disabled == true
steps:
- uses: actions/github-script@v6
- uses: actions/github-script@v7
with:
github-token: ${{ inputs.github-token || secrets.GITHUB_TOKEN }}
script: |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Tests this action failure by the application not being installed on the repository
# Tests this action failure by the application not being installed on the repository / organisation

name: Test Failure - repository - not installed
name: This test should fail

on:
workflow_dispatch:
Expand Down
192 changes: 192 additions & 0 deletions .github/workflows/test-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
# Tests this action success by the application already being installed on the repository

name: Test

on:
pull_request:
branches:
- main
push:
branches:
- main
workflow_dispatch:
inputs:
branch:
description: The name of the branch to checkout for the action
required: true
default: main

# One build per branch, cancel out of date builds only on pull requests
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}

permissions:
contents: read
actions: read
packages: read
deployments: read

jobs:
# Not currently used
# test-installed-repo:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout specified branch
# if: github.event_name == 'workflow_dispatch'
# uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
# with:
# ref: ${{ github.event.inputs.branch }}

# - name: Checkout
# if: github.event_name != 'workflow_dispatch'
# uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4

# - name: Use action
# id: use_action
# uses: ./
# with:
# application_id: ${{ secrets.GHA_APPLICATION_ID }}
# application_private_key: ${{ secrets.GHA_APPLICATION_PRIVATE_KEY }}

# - name: Use token to read details
# uses: actions/github-script@v7 # v6
# with:
# github-token: ${{ steps.use_action.outputs.token }}
# script: |
# const repo = github.rest.repos.get({
# owner: context.repo.owner,
# repo: context.repo.repo,
# })
# console.log(JSON.stringify(repo, null, 2));

# - name: Use token to checkout repository
# uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
# with:
# token: ${{ steps.use_action.outputs.token }}
# repository: sammcj/demo-gha-install-token

test-mocha:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4

- name: Run tests
continue-on-error: true
run: |
npm ci
npm run test
test-installed-limited:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4

- name: Use action
id: use_action
uses: ./
with:
application_id: ${{ secrets.GHA_APPLICATION_ID }}
application_private_key: ${{ secrets.GHA_APPLICATION_PRIVATE_KEY }}
organization: CattleDip
permissions: "contents:read,actions:read,packages:read,deployments:read,workflows:read"

- name: Use token to read details
uses: actions/github-script@v7
with:
github-token: ${{ steps.use_action.outputs.token }}
script: |
const repo = github.rest.repos.get({
owner: 'CattleDip',
repo: 'demo-gha-install-token',
})
console.log(JSON.stringify(repo, null, 2));
- name: Use token to checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
token: ${{ steps.use_action.outputs.token }}
repository: sammcj/demo-gha-install-token

test-installed-org:
runs-on: ubuntu-latest
steps:
- name: Checkout specified branch
if: github.event_name == 'workflow_dispatch'
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
ref: ${{ github.event.inputs.branch }}

- name: Checkout
if: github.event_name != 'workflow_dispatch'
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4

- name: Use action
id: use_action
uses: ./
with:
application_id: ${{ secrets.GHA_APPLICATION_ID }}
application_private_key: ${{ secrets.GHA_APPLICATION_PRIVATE_KEY }}
organization: CattleDip

- name: Use token to read details
uses: actions/github-script@v7
with:
github-token: ${{ steps.use_action.outputs.token }}
script: |
const repo = github.rest.repos.get({
owner: 'CattleDip',
repo: 'demo-gha-install-token',
})
console.log(JSON.stringify(repo, null, 2));
- name: Use token to checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
token: ${{ steps.use_action.outputs.token }}
repository: CattleDip/demo-gha-install-token

# If all tests pass AND we are on main, run the bump and release
release:
runs-on: ubuntu-latest
if: success() && github.ref == 'refs/heads/main'
needs:
# - test-installed-repo
# - test-installed-limited #TODO: get working
- test-installed-org
permissions:
contents: write
packages: write
deployments: write
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4
with:
node-version-file: '.nvmrc'
cache: "npm"
- run: |
npm ci
npm run build
- name: Bump version and push tag
id: tag_version
if: github.ref == 'refs/heads/main'
uses: mathieudutour/github-tag-action@fcfbdceb3093f6d85a3b194740f8c6cec632f4e2 # v6.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
release_branches: main
pre_release_branches: dev
- name: Create a GitHub release
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1
if: github.ref == 'refs/heads/main'
with:
tag: ${{ steps.tag_version.outputs.new_tag }}
name: Release ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
generateReleaseNotes: true
allowUpdates: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading

0 comments on commit 2a8d748

Please sign in to comment.