ci: run fevm-contract-tests on demand and on schedule

This commit is contained in:
galargh
2025-04-27 13:21:40 +02:00
parent 090432ad5b
commit c87458f02a
2 changed files with 123 additions and 16 deletions

View File

@ -8,33 +8,43 @@ inputs:
github-token:
description: Specifies the token to use when calling GitHub APIs while building FFI.
required: false
default: ${{ github.token }}
runs:
using: composite
steps:
- id: inputs
env:
WORKING_DIRECTORY: ${{ inputs.working-directory || '.' }}
FILECOIN_FFI_HEAD_HASH: ${{ hashFiles(format('{0}/.git/modules/extern/filecoin-ffi/HEAD', inputs.working-directory || github.workspace)) }}
run: |
if [[ "$WORKING_DIRECTORY" == '.' ]]; then
echo "key=${RUNNER_OS}-${RUNNER_ARCH}-ffi-${FILECOIN_FFI_HEAD_HASH}" | tee -a $GITHUB_OUTPUT
else
echo "key=${RUNNER_OS}-${RUNNER_ARCH}-ffi-${WORKING_DIRECTORY//\//-}-${FILECOIN_FFI_HEAD_HASH}" | tee -a $GITHUB_OUTPUT
fi
echo "path<<EOF" | tee -a $GITHUB_OUTPUT
echo "${WORKING_DIRECTORY}/extern/filecoin-ffi/filcrypto.h" | tee -a $GITHUB_OUTPUT
echo "${WORKING_DIRECTORY}/extern/filecoin-ffi/libfilcrypto.a" | tee -a $GITHUB_OUTPUT
echo "${WORKING_DIRECTORY}/extern/filecoin-ffi/filcrypto.pc" | tee -a $GITHUB_OUTPUT
echo "${WORKING_DIRECTORY}/extern/build/.filecoin-install" | tee -a $GITHUB_OUTPUT
echo "${WORKING_DIRECTORY}/extern/build/.update-modules" | tee -a $GITHUB_OUTPUT
echo "EOF" | tee -a $GITHUB_OUTPUT
shell: bash
- id: cache-ffi
uses: actions/cache/restore@v4
with:
key: ${{ runner.os }}-${{ runner.arch }}-ffi-${{ hashFiles('./.git/modules/extern/filecoin-ffi/HEAD') }}
path: |
./extern/filecoin-ffi/filcrypto.h
./extern/filecoin-ffi/libfilcrypto.a
./extern/filecoin-ffi/filcrypto.pc
./build/.filecoin-install
./build/.update-modules
key: ${{ steps.inputs.outputs.key }}
path: ${{ steps.inputs.outputs.path }}
- if: steps.cache-ffi.outputs.cache-hit != 'true'
shell: bash
working-directory: ${{ inputs.working-directory || github.workspace }}
env:
GITHUB_TOKEN: ${{ inputs.github-token || github.token }}
run: FFI_PORTABLE=1 make deps
GITHUB_TOKEN: ${{ inputs.github-token }}
run: |
FFI_PORTABLE=1 make deps
- if: steps.cache-ffi.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
key: ${{ runner.os }}-${{ runner.arch }}-ffi-${{ hashFiles('./.git/modules/extern/filecoin-ffi/HEAD') }}
path: |
./extern/filecoin-ffi/filcrypto.h
./extern/filecoin-ffi/libfilcrypto.a
./extern/filecoin-ffi/filcrypto.pc
./build/.filecoin-install
./build/.update-modules
key: ${{ steps.inputs.outputs.key }}
path: ${{ steps.inputs.outputs.path }}

View File

@ -0,0 +1,97 @@
name: FEVM Contract Tests
on:
pull_request:
types:
- opened
- synchronize
- reopened
# WARN: This will run very expensive test every time ANY label is added
- labeled
schedule:
- cron: '0 0 * * *' # Runs nightly at 0AM UTC
workflow_dispatch:
inputs:
lotus-version:
description: Lotus version to test against
required: false
default:
fevm-contract-tests-version:
description: fevm-contract-tests version to test against
required: false
default: main
push: # TODO: Remove this
permissions:
contents: read
issues: write
pull-requests: write
defaults:
run:
shell: bash
jobs:
test:
name: Test
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'need/fevm-contract-tests')
runs-on: ubuntu-latest
steps:
- name: Checkout actions
uses: actions/checkout@v4
with:
path: actions
- name: Checkout lotus
uses: actions/checkout@v4
with:
path: lotus
submodules: 'recursive'
ref: e9393dfe8c429c4afb32a0b1e3f71a65dbae926a # TODO: Replace this with: ${{ inputs.lotus-version || github.ref }}
- name: Checkout fevm-contract-tests
uses: actions/checkout@v4
with:
repository: filecoin-project/fevm-contract-tests
path: fevm-contract-tests
submodules: 'recursive'
ref: ${{ inputs.fevm-contract-tests-version || 'main' }}
- uses: ./actions/.github/actions/install-system-dependencies
- id: go
uses: ./actions/.github/actions/install-go
with:
working-directory: lotus
- uses: ./actions/.github/actions/make-deps
with:
working-directory: lotus
- name: Build the local lotus-runner
env:
GO_VERSION: ${{ steps.go.outputs.version }}
run: |
rm go.mod go.sum
echo "module github.com/filecoin-project/fevm-contract-tests/node" > go.mod
echo "replace github.com/filecoin-project/lotus => ${GITHUB_WORKSPACE}/lotus" >> go.mod
echo "replace github.com/filecoin-project/filecoin-ffi => ${GITHUB_WORKSPACE}/lotus/extern/filecoin-ffi" >> go.mod
go mod tidy
go build -o bin/node ./main.go
working-directory: fevm-contract-tests/node
- name: Install the dependencies
run: make install
working-directory: fevm-contract-tests
- name: Run each test project
run: |
make start-lotus-runner &
make test
working-directory: fevm-contract-tests
issue:
name: Issue
if: failure() && github.event_name == 'schedule'
needs: test
runs-on: ubuntu-latest
steps:
- name: Create issue
uses: ipdxco/create-or-update-issue@v1
with:
GITHUB_TOKEN: ${{ github.token }}
title: FEVM Contract Tests run failed
body: |
The FEVM Contract Tests run failed. See [the workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details.
label: area/fevm-contract-tests