-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Define CI tasks
- Loading branch information
Showing
6 changed files
with
127 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
name: ci | ||
|
||
on: | ||
# Triggers the workflow on push or pull request events | ||
push: | ||
pull_request: | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
jobs: | ||
install: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/cache@v3 | ||
with: | ||
path: | | ||
**/node_modules | ||
.yarn/cache | ||
key: ${{ runner.os }}-yarn-cache-${{ hashFiles('./yarn.lock') }} | ||
- name: yarn-install | ||
# Check out the lockfile from main, reinstall, and then | ||
# verify the lockfile matches what was committed. | ||
run: | | ||
yarn install | ||
CHANGES=$(git status -s) | ||
if [[ ! -z $CHANGES ]]; then | ||
echo "Changes found: $CHANGES" | ||
git diff | ||
exit 1 | ||
fi | ||
build: | ||
runs-on: ubuntu-latest | ||
needs: [install] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/cache@v3 | ||
with: | ||
path: | | ||
**/node_modules | ||
.yarn/cache | ||
key: ${{ runner.os }}-yarn-cache-${{ hashFiles('./yarn.lock') }} | ||
- name: build | ||
run: yarn run build | ||
|
||
prettier: | ||
runs-on: ubuntu-latest | ||
needs: [install] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/cache@v3 | ||
with: | ||
path: | | ||
**/node_modules | ||
.yarn/cache | ||
key: ${{ runner.os }}-yarn-cache-${{ hashFiles('./yarn.lock') }} | ||
- name: prettier | ||
run: | | ||
yarn run prettier | ||
CHANGES=$(git status -s) | ||
if [[ ! -z $CHANGES ]]; then | ||
echo "Changes found: $CHANGES" | ||
exit 1 | ||
fi | ||
test: | ||
runs-on: ubuntu-latest | ||
needs: [build] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/cache@v3 | ||
with: | ||
path: | | ||
**/node_modules | ||
.yarn/cache | ||
key: ${{ runner.os }}-yarn-cache-${{ hashFiles('./yarn.lock') }} | ||
- name: test | ||
run: yarn run test |
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 @@ | ||
{ | ||
"import": ["tsx"] | ||
} |
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 |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
"tsx": "^4.7.1", | ||
"typescript": "5.3.3", | ||
"yaml": "^2.3.1", | ||
"zod": "^3.21.2", | ||
"zod-to-json-schema": "^3.22.5" | ||
}, | ||
"type": "module", | ||
|
@@ -44,7 +45,7 @@ | |
"clean": "rm -rf ./dist ./tmp", | ||
"build": "tsx ./scripts/build.ts && tsc", | ||
"prettier": "prettier --write ./chains ./deployments", | ||
"test": "echo 'TODO'" | ||
"test": "mocha --config .mocharc.json './test/**/*.test.ts' --exit" | ||
}, | ||
"packageManager": "[email protected]" | ||
} |
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,24 @@ | ||
import { ChainMetadataSchema } from '@hyperlane-xyz/sdk'; | ||
import { z } from 'zod'; | ||
import { readAllChainYamlFiles } from './utils'; | ||
|
||
describe('Chain metadata', () => { | ||
it('All chains have valid metadata', () => { | ||
const result = readAllChainYamlFiles('metadata.yaml'); | ||
for (const [chain, metadata] of Object.entries(result)) { | ||
console.log('Validating metadata for', chain); | ||
ChainMetadataSchema.parse(metadata); | ||
} | ||
}); | ||
}); | ||
|
||
describe('Chain addresses', () => { | ||
const AddressSchema = z.record(z.string()); | ||
it('All chain addresses are valid', () => { | ||
const result = readAllChainYamlFiles('addresses.yaml'); | ||
for (const [chain, addresses] of Object.entries(result)) { | ||
console.log('Validating addresses for', chain); | ||
AddressSchema.parse(addresses); | ||
} | ||
}); | ||
}); |
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,17 @@ | ||
import type { ChainMap } from '@hyperlane-xyz/sdk'; | ||
import fs from 'fs'; | ||
import { parse } from 'yaml'; | ||
|
||
export function readAllChainYamlFiles(pattern: string) { | ||
const result: ChainMap<any> = {}; | ||
for (const chainName of fs.readdirSync('./chains')) { | ||
const stat = fs.statSync(`./chains/${chainName}`); | ||
if (!stat.isDirectory()) continue; | ||
const chainFiles = fs.readdirSync(`./chains/${chainName}`); | ||
for (const chainFile of chainFiles) { | ||
if (!chainFile.includes(pattern)) continue; | ||
result[chainName] = parse(fs.readFileSync(`./chains/${chainName}/${chainFile}`, 'utf8')); | ||
} | ||
} | ||
return result; | ||
} |
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