feat: Remove app configuration files #644
Workflow file for this run
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
# Copyright (c) Omar Boukli-Hacene. All rights reserved. | |
# Distributed under an MIT-style license that can be | |
# found in the LICENSE file. | |
# SPDX-License-Identifier: MIT | |
name: Build and test | |
on: | |
pull_request: | |
push: | |
workflow_dispatch: | |
permissions: {} | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: | |
- version: 18.x | |
- version: 20.x | |
run-sonarscanner: true | |
- version: 21.x | |
steps: | |
- name: Check out repository with full history | |
if: ${{ matrix.node-version.run-sonarscanner }} | |
uses: actions/checkout@v3 | |
with: | |
# Shallow clones disabled for a better relevancy of SonarSource analysis. | |
fetch-depth: 0 | |
persist-credentials: false | |
- name: Check out repository | |
if: ${{ ! matrix.node-version.run-sonarscanner }} | |
uses: actions/checkout@v3 | |
with: | |
persist-credentials: false | |
- name: Use Node.js ${{ matrix.node-version.version }} | |
uses: actions/setup-node@v3 | |
with: | |
cache: npm | |
check-latest: false | |
node-version: ${{ matrix.node-version.version }} | |
- name: Configure and update NPM | |
run: |- | |
npm config set fund=false --global | |
npm install --global npm@latest | |
- name: Install packages | |
run: npm ci | |
- name: Check code style | |
run: npx prettier --check . | |
- name: Lint | |
run: npm run lint | |
- name: Build | |
run: npm run build | |
- name: Run unit tests | |
run: npm test | |
- name: Run code coverage instrumented CLI | |
run: |- | |
npx nyc instrument "dist/" "inst/" | |
npx nyc npx montehall --verbose | |
- name: Generate combined code coverage report | |
run: |- | |
cp "test-out/coverage/coverage-final.json" ".nyc_output/unit-test-coverage.json" | |
npx nyc report | |
- name: Analyze with SonarCloud | |
if: ${{ matrix.node-version.run-sonarscanner }} | |
uses: SonarSource/sonarcloud-github-action@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
- name: Run with npx | |
run: npx -- montehall --version | |
- name: Pack | |
id: pack_artifact | |
run: >- | |
echo "artifact_name="$( | |
npm pack --json --pack-destination '${{ runner.temp }}' | |
| jq --raw-output '.[0] | .filename' | |
)"" | |
>> $GITHUB_OUTPUT | |
- name: Install | |
run: npm install --global ${{ steps.pack_artifact.outputs.artifact_name }} | |
working-directory: ${{ runner.temp }} | |
- name: Run integration tests | |
run: |- | |
montehall --version | |
montehall --help | |
montehall | |
montehall --games 11 | |
montehall --random advanced | |
montehall --wise | |
montehall --random advanced --wise | |
montehall --games 0 --random advanced --wise | |
montehall --games 3 --random advanced --wise --verbose | |
montehall --games 100 --table-file ./vendor/numbers.txt | |
montehall --games 100 --table-file ./vendor/numbers.txt --wise | |
montehall --doors 100 --games 100 | |
montehall --doors 100 --games 100 --wise | |
montehall --doors 100 --games 3 --wise --verbose | |
working-directory: ${{ github.workspace }}/.. | |
dependency-check: | |
name: Dependency check | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
with: | |
persist-credentials: false | |
- name: Use latest Node.js LTS | |
uses: actions/setup-node@v3 | |
with: | |
cache: npm | |
check-latest: false | |
node-version: lts/* | |
- name: Configure and update NPM | |
run: |- | |
npm config set fund=false --global | |
npm install --global npm@latest | |
- name: Do non-locked install | |
run: npm install | |
- name: Check if dependency structure can be simplified | |
run: npm dedupe | |
- name: Check if Git tree is dirty | |
run: git diff --exit-code | |
package: | |
name: Pack | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
- dependency-check | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
with: | |
persist-credentials: false | |
- name: Use latest Node.js LTS | |
uses: actions/setup-node@v3 | |
with: | |
cache: npm | |
check-latest: false | |
node-version: lts/* | |
- name: Configure and update NPM | |
run: |- | |
npm config set fund=false --global | |
npm install --global npm@latest | |
- name: Audit dependencies | |
run: npm audit | |
- name: Install packages | |
run: npm ci | |
- name: Build | |
run: npm run build | |
- name: Clean up package.json | |
run: npm pkg delete devDependencies scripts | |
- name: Prune dependencies | |
run: npm prune | |
- name: Pack | |
id: pack_artifact | |
run: >- | |
echo "artifact_name="$( | |
npm pack --json --pack-destination '${{ runner.temp }}' | |
| jq --raw-output '.[0] | .filename' | |
)"" | |
>> $GITHUB_OUTPUT | |
- name: Install | |
run: npm install --global ${{ steps.pack_artifact.outputs.artifact_name }} | |
working-directory: ${{ runner.temp }} | |
- name: Test package | |
run: montehall --version | |
working-directory: ${{ github.workspace }}/.. | |
- name: Upload package artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ steps.pack_artifact.outputs.artifact_name }} | |
path: ${{ runner.temp }}/${{ steps.pack_artifact.outputs.artifact_name }} | |
if-no-files-found: error |