Skip to content

Fix deploy smart contract workflow #18

Fix deploy smart contract workflow

Fix deploy smart contract workflow #18

name: (massa-web3) Unit tests
on:
push:
workflow_call:
jobs:
build:
defaults:
run:
working-directory: ./packages/massa-web3/examples/smartContracts/
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: Install Protoc
uses: arduino/setup-protoc@v1
- name: Install dependencies
run: |
npm ci
working-directory: ./
- name: Build workspace
run: |
npm run build
working-directory: ./
- name: Execute unit tests
run: |
npm ci
npm run build
npm run fmt:check
npm run test
- name: allow access to coverage.sh
run: chmod +x ./scripts/coverage.sh
shell: bash
- name: Extract coverage
id: coverage
run: |
value=$(npm run test:cov | awk '/All files/ {print $10}' | tr -d '%')
echo "coverage=$value" >> $GITHUB_OUTPUT
- name: Add test coverage to README
run: ./scripts/coverage.sh
shell: bash
env:
COVERAGE: ${{ steps.coverage.outputs.coverage }}
- name: Check if coverage changed
id: check_coverage_changed
run: |
echo "::set-output name=coverage_changed::$(git diff --name-only README.md | grep -E '^README.md$')"
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
if: ${{ github.ref == 'refs/heads/main' && steps.check_coverage_changed.outputs.coverage_changed != '' }}
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]>