Skip to content

Commit

Permalink
Merge pull request #3 from jan-guenter/feature/workflow-improvements
Browse files Browse the repository at this point in the history
Workflows and README improvements
  • Loading branch information
jan-guenter committed Apr 18, 2023
2 parents 1ace72f + a6305f0 commit ff672fa
Show file tree
Hide file tree
Showing 9 changed files with 204 additions and 32 deletions.
19 changes: 1 addition & 18 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,7 @@ on:
paths-ignore:
- '**.md'

permissions:
contents: read
pull-requests: write
checks: write
statuses: write
security-events: write
discussions: write
issues: write
permissions: read-all

jobs:
build:
Expand Down Expand Up @@ -92,13 +85,3 @@ jobs:
with:
name: coverage-${{ matrix.runs-on }}
path: coverage

- name: Check Coverage Report
uses: slavcodev/coverage-monitor-action@v1
with:
github_token: ${{ github.token }}
status_context: Coverage Report - ${{ matrix.runs-on }}
coverage_path: coverage/clover.xml
threshold_alert: 70
threshold_warning: 80
threshold_metric: statements
85 changes: 85 additions & 0 deletions .github/workflows/code-scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Code Scan

on:
push:
paths-ignore:
- '**.md'
pull_request:
types: [opened, synchronize, reopened]
paths-ignore:
- '**.md'
schedule:
- cron: '42 13 * * 6'

permissions:
actions: read
contents: read
security-events: write

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: javascript

- name: Setup pnpm
uses: pnpm/action-setup@v2

- name: Determine pnpm store location
id: pnpm-store
run: echo "pnpm-store=$(pnpm store path)" >> "$GITHUB_OUTPUT"

- name: Cache pnpm modules
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-store.outputs.pnpm-store }}
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-
- name: pnpm install
run: pnpm install -r

- name: Build
run: pnpm build

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: /language:javascript

- name: Install ESLint
run: pnpm install -w @microsoft/eslint-formatter-sarif

- name: Run ESLint
run: pnpm eslint
--format @microsoft/eslint-formatter-sarif
--output-file eslint-results.sarif
|| true
continue-on-error: true

- name: Upload eslint results to GitHub
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: eslint-results.sarif

- name: Run njsscan scan
uses: ajinabraham/njsscan-action@v7
with:
args: packages/*/lib/*.js
--sarif
--output njsscan-results.sarif
continue-on-error: true

- name: Upload njsscan report to GitHub
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: njsscan-results.sarif
56 changes: 56 additions & 0 deletions .github/workflows/coverage-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Coverage Report
on:
workflow_run:
workflows: [Build and Test]
types:
- completed

permissions:
contents: read
pull-requests: write
checks: write
statuses: write

jobs:
report:
strategy:
matrix:
runs-on: [ubuntu-latest, macos-latest, windows-latest]
fail-fast: false
runs-on: ${{ matrix.runs-on }}
steps:
- name: Download Coverage Report
uses: actions/github-script@v6
with:
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "coverage-${{ matrix.runs-on }}"
})[0];
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/coverage.zip`, Buffer.from(download.data));
- name: Unzip artifact
run: unzip coverage.zip

- name: Check Coverage Report
uses: slavcodev/coverage-monitor-action@v1
with:
github_token: ${{ github.token }}
status_context: Coverage Report - ${{ matrix.runs-on }}
comment_context: Coverage Report - ${{ matrix.runs-on }}
comment_footer: false
coverage_path: clover.xml
threshold_alert: 70
threshold_warning: 80
threshold_metric: statements
5 changes: 3 additions & 2 deletions .github/workflows/test-report.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
name: 'Test Report'
name: Test Report
on:
workflow_run:
workflows: ['Build and Test']
workflows: [Build and Test]
types:
- completed

permissions:
contents: read
checks: write
statuses: write

jobs:
report:
Expand Down
5 changes: 4 additions & 1 deletion .jscpd.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
"**/*.svg",
"packages/*/lib/**",
"packages/*/__tests__/**",
"packages/example-action/src/**"
"packages/example-action/src/**",
"megalinter-reports/**",
"coverage/**",
"reports/**"
]
}
48 changes: 46 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,48 @@
# GitHub Action class framework

- [`@action-class/core`](packages/core) is a framework for creating GitHub Actions in TypeScript.
- [`@action-class/action-yml`](packages/action-yml) is a type library for reading and writing `action.yml` files.
[![Build and Test](https://img.shields.io/github/actions/workflow/status/jan-guenter/action-class/build-and-test.yml?branch=main&label=Build%20and%20Test&logo=github)](https://github.com/jan-guenter/action-class/actions/workflows/build-and-test.yml)
[![Test Report](https://img.shields.io/github/actions/workflow/status/jan-guenter/action-class/test-report.yml?branch=main&label=Test%20Report&logo=github)](https://github.com/jan-guenter/action-class/actions/workflows/test-report.yml)
[![Coverage Report](https://img.shields.io/github/actions/workflow/status/jan-guenter/action-class/coverage-report.yml?branch=main&label=Coverage%20Report&logo=github)](https://github.com/jan-guenter/action-class/actions/workflows/coverage-report.yml)
[![MegaLinter](https://img.shields.io/github/actions/workflow/status/jan-guenter/action-class/mega-linter.yml?branch=main&label=MegaLinter&logo=github)](https://github.com/jan-guenter/action-class/actions/workflows/mega-linter.yml)

[![GitHub last commit](https://img.shields.io/github/last-commit/jan-guenter/action-class?logo=github)](https://github.com/jan-guenter/action-class/graphs/commit-activity)
[![GitHub issues](https://img.shields.io/github/issues/jan-guenter/action-class?logo=github)](https://github.com/jan-guenter/action-class/issues)
[![GitHub pull requests](https://img.shields.io/github/issues-pr/jan-guenter/action-class?logo=github)](https://github.com/jan-guenter/action-class/pulls)
[![GitHub commit activity](https://img.shields.io/github/commit-activity/y/jan-guenter/action-class?logo=github)](https://github.com/jan-guenter/action-class/graphs/commit-activity)
[![GitHub contributors](https://img.shields.io/github/contributors/jan-guenter/action-class?logo=github)](https://github.com/jan-guenter/action-class/graphs/contributors)

## Packages

---

### [`@action-class/core`](packages/core)

A framework for creating GitHub Actions in TypeScript.

[![npm](https://img.shields.io/npm/v/@action-class/core?logo=npm)](https://www.npmjs.com/package/@action-class/core)
[![Downloads](https://img.shields.io/npm/dt/@action-class/core?logo=npm)](https://www.npmjs.com/package/@action-class/core)
[![License](https://img.shields.io/npm/l/@action-class/core)](packages/core/LICENSE)

<!-- markdown-link-check-disable-next-line -->
[![Dependencies](https://img.shields.io/librariesio/release/npm/@action-class/core?logo=npm)](https://libraries.io/npm/@action-class%2Fcore/tree)
![Dependents](https://img.shields.io/librariesio/dependents/npm/@action-class/core?logo=npm)
[![SourceRank](https://img.shields.io/librariesio/sourcerank/npm/@action-class/core)](https://libraries.io/npm/@action-class%2Fcore/sourcerank)

A detailed description can be found in the package [README](packages/core/README.md)

---

### [`@action-class/action-yml`](packages/action-yml)

A type library for reading and writing `action.yml` files.

[![NPM](https://img.shields.io/npm/v/@action-class/action-yml?logo=npm)](https://www.npmjs.com/package/@action-class/action-yml)
[![Downloads](https://img.shields.io/npm/dt/@action-class/action-yml?logo=npm)](https://www.npmjs.com/package/@action-class/action-yml)
[![License](https://img.shields.io/npm/l/@action-class/action-yml)](packages/core/LICENSE)

<!-- markdown-link-check-disable-next-line -->
[![Dependencies](https://img.shields.io/librariesio/release/npm/@action-class/action-yml?logo=npm)](https://libraries.io/npm/@action-class%2Faction-yml/tree)
![Dependents](https://img.shields.io/librariesio/dependents/npm/@action-class/action-yml?logo=npm)
[![SourceRank](https://img.shields.io/librariesio/sourcerank/npm/@action-class/action-yml?logo=npm)](https://libraries.io/npm/@action-class%2Faction-yml/sourcerank)

A detailed description can be found in the package [README](packages/action-yml/README.md)
6 changes: 3 additions & 3 deletions packages/action-yml/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"actions",
"yaml"
],
"homepage": "https://github.com/jan-guenter/actions-class/tree/main/packages/action-yml",
"homepage": "https://github.com/jan-guenter/action-class/tree/main/packages/action-yml",
"license": "MIT",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand All @@ -29,15 +29,15 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/jan-guenter/actions-class.git",
"url": "https://github.com/jan-guenter/action-class.git",
"directory": "packages/action-yml"
},
"scripts": {
"test": "echo \"Error: run tests from root\" && exit 1",
"tsc": "tsc"
},
"bugs": {
"url": "https://github.com/jan-guenter/actions-class/issues"
"url": "https://github.com/jan-guenter/action-class/issues"
},
"devDependencies": {
"@types/feather-icons": "^4.29.1",
Expand Down
6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"github",
"actions"
],
"homepage": "https://github.com/jan-guenter/actions-class/tree/main/packages/core",
"homepage": "https://github.com/jan-guenter/action-class/tree/main/packages/core",
"license": "MIT",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand All @@ -31,15 +31,15 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/jan-guenter/actions-class.git",
"url": "https://github.com/jan-guenter/action-class.git",
"directory": "packages/core"
},
"scripts": {
"test": "echo \"Error: run tests from root\" && exit 1",
"tsc": "tsc"
},
"bugs": {
"url": "https://github.com/jan-guenter/actions-class/issues"
"url": "https://github.com/jan-guenter/action-class/issues"
},
"dependencies": {
"@action-class/action-yml": "workspace:^",
Expand Down
6 changes: 3 additions & 3 deletions packages/example-action/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"actions",
"example"
],
"homepage": "https://github.com/jan-guenter/actions-class/tree/main/packages/example-action",
"homepage": "https://github.com/jan-guenter/action-class/tree/main/packages/example-action",
"license": "MIT",
"main": "lib/example-action.js",
"types": "lib/example-action.d.ts",
Expand All @@ -30,7 +30,7 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/jan-guenter/actions-class.git",
"url": "https://github.com/jan-guenter/action-class.git",
"directory": "packages/example-action"
},
"scripts": {
Expand All @@ -40,7 +40,7 @@
"build": "npm run tsc && npm run action-yml"
},
"bugs": {
"url": "https://github.com/jan-guenter/actions-class/issues"
"url": "https://github.com/jan-guenter/action-class/issues"
},
"dependencies": {
"@action-class/action-yml": "workspace:^",
Expand Down

0 comments on commit ff672fa

Please sign in to comment.