Skip to content

refactor findCheapestSlot #330

refactor findCheapestSlot

refactor findCheapestSlot #330

Workflow file for this run

name: Unit tests
on:
push:
workflow_call:
jobs:
build:
runs-on: ubuntu-latest
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the changed files back to the repository.
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
# https://github.com/actions/checkout/issues/298#issuecomment-664976337
ref: ${{ github.head_ref }}
# Checkout code using massabot account
token: ${{ secrets.MASSABOTCLASSIC || github.token }}
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: 'npm'
- name: Execute unit tests
run: |
npm ci
npm run fmt:check
npm run test:ci
- id: coverage
name: Extract coverage
run: |
value=$(npm run test:ci | grep -oE '^│\s*total\s+\│\s*([0-9.]+)%' | grep -oE '[0-9]+(\.[0-9]+)?%' | cut -d'.' -f1)
echo "coverage=$value" >> $GITHUB_OUTPUT
- name: Add test coverage to README
run: .github/coverage.sh
shell: bash
env:
COVERAGE: ${{ steps.coverage.outputs.coverage }}
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "Generate coverage badge"
file_pattern: "README.md"
# Commit code using massabot account that can bypass push and MR restriction
commit_author: massabot <[email protected]>