Skip to content

chore: add .gitattributes #4

chore: add .gitattributes

chore: add .gitattributes #4

Workflow file for this run

name: foundry-test
on:
pull_request:
push:
branches:
- main
workflow_call:
inputs:
testCommand:
default: forge test -vv
description: the command responsible for running the test
type: string
required: false
secrets:
RPC_MAINNET:
required: false
RPC_POLYGON:
required: false
RPC_AVALANCHE:
required: false
RPC_OPTIMISM:
required: false
RPC_ARBITRUM:
required: false
COMMENT_PAT:
required: false
jobs:
test:
name: Foundry build n test
runs-on: ubuntu-latest
env:
FOUNDRY_PROFILE: ci
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup env
run: |
if [[ "${{ secrets.RPC_MAINNET }}" != "" ]] ; then echo "RPC_MAINNET=${{ secrets.RPC_MAINNET }}" >> $GITHUB_ENV ; fi
if [[ "${{ secrets.RPC_POLYGON }}" != "" ]] ; then echo "RPC_POLYGON=${{ secrets.RPC_POLYGON }}" >> $GITHUB_ENV ; fi
if [[ "${{ secrets.RPC_AVALANCHE }}" != "" ]] ; then echo "RPC_AVALANCHE=${{ secrets.RPC_AVALANCHE }}" >> $GITHUB_ENV ; fi
if [[ "${{ secrets.RPC_OPTIMISM }}" != "" ]] ; then echo "RPC_OPTIMISM=${{ secrets.RPC_OPTIMISM }}" >> $GITHUB_ENV ; fi
if [[ "${{ secrets.RPC_ARBITRUM }}" != "" ]] ; then echo "RPC_ARBITRUM=${{ secrets.RPC_ARBITRUM }}" >> $GITHUB_ENV ; fi
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Copy .env
run: |
cp .env.example .env 2> /dev/null || :
- uses: actions/setup-node@v3
with:
node-version: 18
registry-url: "https://registry.npmjs.org"
cache: "yarn"
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Run Forge build
run: |
forge --version | sed -r 's/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g' | tee /tmp/foundry_version ; test ${PIPESTATUS[0]} -eq 0
forge cache ls
forge build | sed -r 's/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g' | tee /tmp/foundry_build ; test ${PIPESTATUS[0]} -eq 0
id: build
- name: Run Forge tests
run: |
forge test -vv | sed -r 's/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g' | tee /tmp/foundry_test
echo "testStatus=${PIPESTATUS[0]}" >> $GITHUB_ENV
id: test
- name: Create comment body
id: get-comment-body
run: |
printf "Foundry report\n\n" > /tmp/template.md
printf "\`\`\`shell\n$(cat /tmp/foundry_version)\n\`\`\`\n\n" >> /tmp/template.md
printf "<details><summary>Build log</summary>\n\n\`\`\`shell\n$(cat /tmp/foundry_build)\n\`\`\`\n</details>\n\n" >> /tmp/template.md
printf "<details><summary>Test ${{ env.testStatus == 0 && 'success :rainbow:' || 'error :finnadie::x:'}}</summary>\n\n\`\`\`shell\n$(cat /tmp/foundry_test)\n\`\`\`\n</details>\n\n" >> /tmp/template.md
- uses: actions/upload-artifact@v3
with:
name: ${{ github.event.pull_request.head.sha || github.sha }}
path: /tmp/template.md
- name: Save PR number
if: github.event_name == 'pull_request'
env:
PR_NUMBER: ${{ github.event.number }}
run: |
mkdir -p ./pr
echo $PR_NUMBER > ./pr/pr_number.txt
- uses: actions/upload-artifact@v3
if: github.event_name == 'pull_request'
with:
name: pr_number
path: pr/pr_number.txt
# we let failing tests pass so we can log them in the comment, still we want the ci to fail
- name: Post test
if: ${{ env.testStatus != 0 }}
run: |
echo "tests failed"
exit 1