📦 Package › Tests #46
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "📦 Package › Tests" | |
run-name: "📦 Package › Tests" | |
on: | |
push: | |
branches: | |
- '+([0-9])?(.{+([0-9]),x}).x' | |
- 'main' | |
- '!all-contributors/**' | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
job-tests-run: | |
name: >- | |
📦 Test | |
if: | | |
${{ !contains(github.head_ref, 'all-contributors') }} | |
strategy: | |
matrix: | |
os: [windows-latest, macOS-latest, ubuntu-latest] | |
node-version: [14.x, 16.x, 18.x, 20.x, 21.x] | |
runs-on: ${{ matrix.os }} | |
env: | |
CI: true | |
permissions: | |
contents: write | |
packages: write | |
steps: | |
# --------------------------------------------------------------------------------------- | |
# Job > Tests > Fix Line Endings | |
# --------------------------------------------------------------------------------------- | |
- name: "🛒 Fix Git Checkout Line Endings" | |
id: task_tests_git-fixlines | |
run: | | |
git config --global core.autocrlf input | |
# --------------------------------------------------------------------------------------- | |
# Job > Tests > Checkout | |
# --------------------------------------------------------------------------------------- | |
- name: "☑️ Checkout" | |
id: task_tests_run_checkout | |
uses: actions/checkout@v4 | |
# --------------------------------------------------------------------------------------- | |
# Job > Tests > Cancel existing runs | |
# --------------------------------------------------------------------------------------- | |
- name: "🛑 Cancel Previous Runs" | |
uses: styfle/cancel-workflow-action@0.12.1 | |
with: | |
access_token: ${{ secrets.ADMINSERV_TOKEN_CL }} | |
# --------------------------------------------------------------------------------------- | |
# Job > Tests > Setup Node | |
# --------------------------------------------------------------------------------------- | |
- name: "⚙️ Setup Node" | |
id: task_tests_node_setup | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
registry-url: 'https://registry.npmjs.org/' | |
always-auth: true | |
scope: '@aetherinox' | |
# --------------------------------------------------------------------------------------- | |
# Job > Tests > Get NPM Cache Directory | |
# --------------------------------------------------------------------------------------- | |
- name: "📂 Get NPM Cache Directory" | |
id: task_tests_npm_cache_dir_get | |
run: | | |
echo "::set-output name=dir::$(npm config get cache)" | |
# --------------------------------------------------------------------------------------- | |
# Job > Tests > NPM Cache | |
# --------------------------------------------------------------------------------------- | |
- name: "📑 NPM cache" | |
id: task_tests_npm_cache_dir_run # use this to check for `cache-hit` ==> if: steps.task_tests_npm_cache_dir_run.outputs.cache-hit != 'true' | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.task_tests_npm_cache_dir_get.outputs.dir }} | |
key: ${{ runner.OS }}-node-${{ hashFiles('**/package.json') }} | |
restore-keys: | | |
${{ runner.OS }}-node- | |
# --------------------------------------------------------------------------------------- | |
# Job > Tests > NPM Install | |
# --------------------------------------------------------------------------------------- | |
- name: "📦 NPM › Install" | |
id: task_tests_npm_install | |
run: | | |
npm install | |
# --------------------------------------------------------------------------------------- | |
# Job > Tests > NPM Pretty and Linter | |
# --------------------------------------------------------------------------------------- | |
- name: "📦 NPM › Pretty & Linter" | |
id: task_tests_npm_prettylint | |
run: | | |
npm run pretty | |
npm run lint | |
# --------------------------------------------------------------------------------------- | |
# Job > Tests > Run Validation Script | |
# --------------------------------------------------------------------------------------- | |
- name: "▶️ Run Build" | |
run: | | |
npm run validate | |
# --------------------------------------------------------------------------------------- | |
# Job > Tests > Upload Coverage to Codecov | |
# --------------------------------------------------------------------------------------- | |
- name: "📝 Upload Coverage Reports › Codecov" | |
id: task_tests_codecov_upload | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
slug: Aetherinox/noxenv | |
env_vars: CI_OS,NODE_VERSION | |
env: | |
CI_OS: ${{ matrix.os }} | |
NODE_VERSION: ${{ matrix.node-version }} | |
# --------------------------------------------------------------------------------------- | |
# JOB > TESTS > COMPLETE | |
# --------------------------------------------------------------------------------------- | |
job-tests-complete: | |
name: >- | |
📦 Tests › Complete | |
needs: job-tests-run | |
runs-on: ubuntu-latest | |
steps: | |
- name: "☑️ Tests Complete" | |
id: task_tests_complete | |
run: | | |
echo 'Tests passed' |