Skip to content

Update CI

Update CI #47

Workflow file for this run

name: CI
on:
push:
workflow_dispatch:
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build contracts
id: build
run: npm run compile
- name: 'Add build summary'
if: ${{ success() || failure() }}
run: |
echo "## Build result" >> $GITHUB_STEP_SUMMARY
- name: 'Add build result (success)'
if: ${{ success() && steps.build.outcome == 'success' }}
run: |
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
- name: 'Add build result (failed)'
if: ${{ failure() && steps.build.outcome == 'failure' }}
run: |
echo "❌ Failed" >> $GITHUB_STEP_SUMMARY
test:
name: Test
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Test contracts
id: run_tests
run: |
(npm run --silent test >> /tmp/TEST_OUTPUT) || FAILED=1
{
echo "test_output<<RANDOM_DELIMITER_THAT_MOST_DEFINITELY_WONT_APPEAR_IN_TEXT"
cat /tmp/TEST_OUTPUT
echo "RANDOM_DELIMITER_THAT_MOST_DEFINITELY_WONT_APPEAR_IN_TEXT"
} >> "$GITHUB_OUTPUT"
cat /tmp/TEST_OUTPUT
if [ ${FAILED:-0} -eq 1 ]
then
exit 1
fi
- name: 'Add test summary'
if: ${{ success() || failure() }}
run: |
echo "## Tests result" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "${{steps.run_tests.outputs.test_output}}" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
- name: 'Add test result (success)'
if: ${{ success() && steps.run_tests.outcome == 'success' }}
run: |
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
- name: 'Add test result (failed)'
if: ${{ failure() && steps.run_tests.outcome == 'failure' }}
run: |
echo "❌ Failed" >> $GITHUB_STEP_SUMMARY
slither:
name: Slither
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup reviewdog
uses: reviewdog/action-setup@v1
with:
reviewdog_version: latest
- name: Run Slither
uses: crytic/[email protected]
id: slither
with:
node-version: 20
sarif: 'results.sarif'
fail-on: none
slither-args: --filter-paths node_modules/
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: ${{ steps.slither.outputs.sarif }}