Skip to content

ci: e2e + 3rd party-lib watcher #32

ci: e2e + 3rd party-lib watcher

ci: e2e + 3rd party-lib watcher #32

name: Third party libraries testing workflow
# By default the sha where it runs is latest commit on default branch
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
on:
schedule:
# hourly
- cron: 0 * * * *
workflow_dispatch:
pull_request:
jobs:
compare-versions:
name: check if new version of ${{ matrix.lib }} is out
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
lib:
- 'viem'
- 'web3'
- 'ethers'
steps:
- uses: actions/checkout@v4
with:
# TODO: REMOVE THIS
ref: nicolasbrugneaux/ci-watcher
sparse-checkout: |
.github
- uses: actions/download-artifact@v4
name: Download last version tested
with:
name: /${{ github.workspace }}/cache-last-version-${{ matrix.lib }}
path: /${{ github.workspace }}/
continue-on-error: true
- uses: actions/setup-node@v4
name: Setup NPM
- id: npm-version
name: Fetch latest available version from NPM
run: |
echo "result=$(npm info ${{ matrix.lib }} --json | jq -r ".version")" >> "$GITHUB_OUTPUT"
- name: Install semver-tool
run: |
# https://github.com/fsaintjacques/semver-tool
# Download the script and save it to /usr/local/bin
wget -O /usr/local/bin/semver \
https://raw.githubusercontent.com/fsaintjacques/semver-tool/master/src/semver
# Make script executable
chmod +x /usr/local/bin/semver
# Prove it works
semver --version
- id: compare-version
name: Compare last version with NPM's version
run: |
LAST_VERSION=$(cat /${{ github.workspace }}/cache-last-version-${{ matrix.lib }}2>/dev/null || echo '0.0.0')
FETCHED_VERSION="${{ steps.npm-version.outputs.result }}"
echo "Validating last version: $LAST_VERSION ..."
semver validate $LAST_VERSION
echo "Validating fetched version: $FETCHED_VERSION ..."
semver validate $FETCHED_VERSION
echo "result=$(semver compare $LAST_VERSION $FETCHED_VERSION)" >> "$GITHUB_OUTPUT"
- run: ls -lA .
- id: trigger-tests
name: Trigger tests if NPM's version was higher than tested version
if: ${{ steps.compare-version.outputs.result }} == -1
uses: ./.github/actions/third-party-tests
with:
lib: ${{ matrix.lib }}
version: ${{ steps.npm-version.outputs.result }}
network: alfajores
env:
# Increment these to force cache rebuilding
NODE_MODULE_CACHE_VERSION: 5
NODE_OPTIONS: '--max-old-space-size=4096'
TERM: dumb
TEST_ACCOUNT: ${{ secrets.TEST_ACCOUNT }}
- id: save-version
name: Save the tested version
run: |
echo $VERSION_TO_SAVE >> /${{ github.workspace }}/cache-last-version-${{ matrix.lib }}
env:
VERSION_TO_SAVE: ${{ steps.npm-version.outputs.result }}
- uses: actions/upload-artifact@v4
name: Upload version
with:
name: cache-last-version-${{ matrix.lib }}
path: /${{ github.workspace }}/