build: initialize JavaScript Action project (#69)

* build: initialize JavaScript action project

* chore(dependabot): check for npm package updates

* style: ignore `main` dir and `README.md` from being formatted

* ci: add Build workflow that contains Build Package job

* ci: add Test Package job in the Test workflow

* test: add an empty `main.test.ts` test

* chore: adjust Git attributes for `main/index.mjs` file

* docs(readme): add a build status badge
This commit is contained in:
Alfi Maulana 2023-11-20 18:25:22 +07:00 committed by GitHub
parent d27fb54a3f
commit ed7c2d179c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 4726 additions and 1 deletions

28
.eslintrc.json Normal file
View File

@ -0,0 +1,28 @@
{
"root": true,
"extends": ["eslint:recommended", "prettier"],
"parserOptions": {
"ecmaVersion": 2022,
"sourceType": "module"
},
"overrides": [
{
"files": ["**/*.mts", "**/*.ts"],
"extends": ["plugin:@typescript-eslint/recommended"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": ["tsconfig.eslint.json"]
},
"plugins": ["@typescript-eslint", "eslint-plugin-tsdoc"],
"rules": {
"tsdoc/syntax": "error"
}
},
{
"files": ["**/*.test.*"],
"env": {
"jest": true
}
}
]
}

1
.gitattributes vendored Normal file
View File

@ -0,0 +1 @@
main/index.mjs -diff linguist-generated=true

View File

@ -7,3 +7,12 @@ updates:
commit-message: commit-message:
prefix: chore prefix: chore
labels: [chore] labels: [chore]
- package-ecosystem: npm
directory: /
schedule:
interval: daily
commit-message:
prefix: chore
labels: [chore]
versioning-strategy: increase

39
.github/workflows/build.yaml vendored Normal file
View File

@ -0,0 +1,39 @@
name: Build
on:
workflow_dispatch:
pull_request:
push:
branches: [main]
jobs:
build-package:
name: Build Package
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.1.1
- name: Setup Node.js
uses: actions/setup-node@v4.0.0
with:
node-version: latest
- name: Update Yarn
run: corepack enable && yarn set version stable
- name: Cache deps
uses: actions/cache@v3.3.2
with:
path: .yarn
key: yarn-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
- name: Install deps
run: yarn install
- name: Check lib
run: yarn check
- name: Bundle dist
run: yarn bundle
- name: Check diff
run: git diff --exit-code HEAD

View File

@ -5,6 +5,36 @@ on:
push: push:
branches: [latest, main] branches: [latest, main]
jobs: jobs:
test-package:
name: Test Package
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os: [windows, ubuntu, macos]
env:
NODE_OPTIONS: --experimental-vm-modules
steps:
- name: Checkout
uses: actions/checkout@v4.1.1
- name: Setup Node.js
uses: actions/setup-node@v4.0.0
with:
node-version: latest
- name: Cache deps
uses: actions/cache@v3.3.2
with:
path: .yarn
key: yarn-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
- name: Install deps
run: corepack enable && yarn install
- name: Test lib
run: yarn test
default-usage: default-usage:
runs-on: ${{ matrix.os }}-latest runs-on: ${{ matrix.os }}-latest
strategy: strategy:

6
.gitignore vendored
View File

@ -1,4 +1,8 @@
.* .*
!.eslint*
!.git* !.git*
build build/
coverage/
dist/
node_modules/

View File

@ -2,6 +2,7 @@
[![Latest Version](https://img.shields.io/github/v/release/threeal/cmake-action)](https://github.com/threeal/cmake-action/releases/) [![Latest Version](https://img.shields.io/github/v/release/threeal/cmake-action)](https://github.com/threeal/cmake-action/releases/)
[![License](https://img.shields.io/github/license/threeal/cmake-action)](./LICENSE) [![License](https://img.shields.io/github/license/threeal/cmake-action)](./LICENSE)
[![Build Status](https://img.shields.io/github/actions/workflow/status/threeal/cmake-action/build.yaml?branch=main)](https://github.com/threeal/cmake-action/actions/workflows/build.yaml)
[![Test Status](https://img.shields.io/github/actions/workflow/status/threeal/cmake-action/test.yml?label=test&branch=main)](https://github.com/threeal/cmake-action/actions/workflows/test.yml) [![Test Status](https://img.shields.io/github/actions/workflow/status/threeal/cmake-action/test.yml?label=test&branch=main)](https://github.com/threeal/cmake-action/actions/workflows/test.yml)
Configure, build, and test your [CMake](https://cmake.org/) project using [GitHub Actions](https://github.com/features/actions). This action simplifies the workflow for configuring the build environment of a CMake project. It can also be optionally specified to build a CMake project using the `cmake --build` command and test it using the `ctest` command. Configure, build, and test your [CMake](https://cmake.org/) project using [GitHub Actions](https://github.com/features/actions). This action simplifies the workflow for configuring the build environment of a CMake project. It can also be optionally specified to build a CMake project using the `cmake --build` command and test it using the `ctest` command.

19
jest.config.json Normal file
View File

@ -0,0 +1,19 @@
{
"collectCoverage": true,
"coverageThreshold": {
"global": {
"branches": 100,
"functions": 100,
"lines": 100,
"statements": 100
}
},
"extensionsToTreatAsEsm": [".ts", ".mts"],
"moduleNameMapper": {
"^(\\.{1,2}/.*)\\.mjs$": "$1.mts"
},
"testMatch": ["**/*.test.ts"],
"transform": {
"^.+\\.m?ts$": ["ts-jest", { "useESM": true }]
}
}

8
main/index.mjs generated Normal file
View File

@ -0,0 +1,8 @@
/******/ /* webpack/runtime/compat */
/******/
/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = new URL('.', import.meta.url).pathname.slice(import.meta.url.match(/^file:\/\/\/\w:/) ? 1 : 0, -1) + "/";
/******/
/************************************************************************/
var __webpack_exports__ = {};
//# sourceMappingURL=main.mjs.map

27
package.json Normal file
View File

@ -0,0 +1,27 @@
{
"name": "cmake-action",
"private": true,
"type": "module",
"scripts": {
"bundle": "tsc && ncc build dist/main.mjs -o main",
"check": "sort-package-json && prettier --write . !main !README.md && eslint src",
"test": "jest"
},
"devDependencies": {
"@jest/globals": "^29.7.0",
"@types/jest": "^29.5.8",
"@types/node": "^20.9.0",
"@typescript-eslint/eslint-plugin": "^6.11.0",
"@typescript-eslint/parser": "^6.11.0",
"@vercel/ncc": "^0.38.1",
"eslint": "^8.53.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-tsdoc": "^0.2.17",
"jest": "^29.7.0",
"prettier": "^3.1.0",
"sort-package-json": "^2.6.0",
"ts-jest": "^29.1.1",
"typescript": "^5.2.2"
},
"packageManager": "yarn@4.0.2"
}

0
src/main.mts Normal file
View File

1
src/main.test.ts Normal file
View File

@ -0,0 +1 @@
test("some test", () => {});

4
tsconfig.eslint.json Normal file
View File

@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": []
}

17
tsconfig.json Normal file
View File

@ -0,0 +1,17 @@
{
"compilerOptions": {
"strict": true,
"module": "NodeNext",
"moduleResolution": "NodeNext",
"declaration": true,
"outDir": "dist",
"sourceMap": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"lib": ["ES2022"],
"target": "ES2022",
"skipLibCheck": true
},
"include": ["src"],
"exclude": ["**/*.test.*"]
}

4537
yarn.lock Normal file

File diff suppressed because it is too large Load Diff