npm(deps-dev): bump @babel/core from 7.22.15 to 7.22.17 (#361) #811
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
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | |
name: Test | |
on: | |
push: | |
branches: [ main ] | |
paths-ignore: | |
# Can we use '**.md' ? | |
- 'README.md' | |
- 'SECURITY.md' | |
- 'CONTRIBUTING.md' | |
- 'CODE_OF_CONDUCT.md' | |
- 'LICENSE' | |
- '.gitignore' | |
pull_request: | |
branches: [ main ] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [16.x] | |
# Map a step output to a job output | |
outputs: | |
coverage: ${{ steps.coverage.outputs.coverage }} | |
coverage-rounded-display: ${{ steps.coverage.outputs.coverage-rounded-display }} | |
test-badge: ${{ steps.test.outputs.badge }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3.8.1 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Manage cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
node_modules | |
key: ${{ runner.OS }}-build-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('.github/workflows/*.yml') }} | |
restore-keys: | | |
${{ runner.OS }}-build-${{ hashFiles('**/yarn.lock') }} | |
${{ runner.OS }}-build | |
- name: yarn install and test | |
id: test | |
run: | | |
yarn --immutable --color | |
yarn test | |
mkdir badges | |
cp -parv ./dist/ .github/action/ | |
- name: Generate test badge using current code | |
uses: ./.github/action | |
with: | |
label: 'Tested' | |
status: 'true' | |
color: 'green' | |
path: badges/tested.svg | |
# Coverage badges will be updated on any branch | |
# and saved into a dedicated one | |
- name: Check test coverage | |
uses: johanvanhelden/gha-clover-test-coverage-check@v1 | |
id: coverage | |
with: | |
percentage: 50 | |
exit: 0 | |
rounded-precision: 2 | |
filename: "coverage/clover.xml" | |
badge: | |
# Only generate and publish if these conditions are met: | |
# - The test step ended successfully | |
# - One of these is met: | |
# - This is a pull request event and the pull actor is the same as the repo owner | |
# - This is a push event and the push event is on branch 'main' | |
needs: test | |
if: ${{ ( github.event_name == 'pull_request' && github.actor == github.repository_owner ) || github.ref == 'refs/heads/main' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Extract branch name | |
shell: bash | |
run: | | |
TMP_PULL_HEAD_REF="${{ github.head_ref }}" | |
TMP_GITHUB_REF="${GITHUB_REF#refs/heads/}" | |
EXPORT_VALUE="" | |
if [ "${TMP_PULL_HEAD_REF}" != "" ] | |
then | |
EXPORT_VALUE="${TMP_PULL_HEAD_REF}" | |
else | |
EXPORT_VALUE="${TMP_GITHUB_REF}" | |
fi | |
echo "branch=${EXPORT_VALUE}" >> "${GITHUB_OUTPUT}" | |
id: extract_branch | |
- uses: actions/checkout@v4 | |
with: | |
ref: badges | |
path: badges | |
# Use the output from the `coverage` step | |
- name: Generate the badge SVG image | |
uses: emibcn/badge-action@v2.0.2 | |
id: badge | |
with: | |
label: 'Coverage' | |
status: ${{ needs.test.outputs.coverage-rounded-display }} | |
color: ${{ | |
needs.test.outputs.coverage > 90 && 'green' || | |
needs.test.outputs.coverage > 80 && 'yellow,green' || | |
needs.test.outputs.coverage > 70 && 'yellow' || | |
needs.test.outputs.coverage > 60 && 'orange,yellow' || | |
needs.test.outputs.coverage > 50 && 'orange' || | |
needs.test.outputs.coverage > 40 && 'red,orange' || | |
needs.test.outputs.coverage > 30 && 'red,red,orange' || | |
needs.test.outputs.coverage > 20 && 'red,red,red,orange' || | |
'red' }} | |
path: badges/test-coverage.svg | |
- name: Commit badge | |
env: | |
BRANCH: ${{ steps.extract_branch.outputs.branch }} | |
FILE: 'test-coverage.svg' | |
TEST_BADGE: ${{ needs.test.outputs.test-badge }} | |
TEST_BADGE_FILE: test-badge.svg | |
working-directory: ./badges | |
run: | | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
mkdir -p "${BRANCH}" | |
mv "${FILE}" "${BRANCH}" | |
echo -n "${TEST_BADGE}" > "${BRANCH}/${TEST_BADGE_FILE}" | |
git add "${BRANCH}/${FILE}" "${BRANCH}/${TEST_BADGE_FILE}" | |
# Will give error if badge did not changed | |
git commit -m "Add/Update badge" || true | |
- name: Push badge commit | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: badges | |
directory: badges |