Skip to content
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

Init script and CI #1

Merged
merged 20 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .forge-snapshots/OsToken_burn.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
25718
51443
2 changes: 1 addition & 1 deletion .forge-snapshots/OsToken_mint.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
69279
92623
2 changes: 1 addition & 1 deletion .forge-snapshots/OsToken_permit.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
73680
96780
2 changes: 1 addition & 1 deletion .forge-snapshots/OsToken_setController.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
49094
70438
2 changes: 1 addition & 1 deletion .forge-snapshots/OsToken_setRate.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
47164
70508
2 changes: 1 addition & 1 deletion .forge-snapshots/OsToken_setRateReceiver.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
48334
69538
Original file line number Diff line number Diff line change
@@ -1 +1 @@
71593
98405
2 changes: 1 addition & 1 deletion .forge-snapshots/PriceFeedReceiver_syncRate.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
43468
64812
12 changes: 12 additions & 0 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
DeployOsToken:test() (gas: 168)
DeployOsTokenPriceFeed:test() (gas: 176)
DeployOsTokenPriceFeedSender:test() (gas: 176)
OsTokenTest:test_Permit() (gas: 340552)
OsTokenTest:test_burn() (gas: 206082)
OsTokenTest:test_mint() (gas: 183400)
OsTokenTest:test_setController() (gas: 141208)
PriceFeedReceiverTest:test_receiveWormholeMessages() (gas: 598275)
PriceFeedSenderTest:test_quoteRateSync() (gas: 362656)
PriceFeedSenderTest:test_syncRate() (gas: 490128)
PriceFeedTest:test_setRate() (gas: 201414)
PriceFeedTest:test_setRateReceiver() (gas: 113529)
89 changes: 89 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: code coverage

on:
pull_request:
branches:
- main

jobs:
comment-forge-coverage:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Install foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Run Forge build
run: |
forge --version
forge build --sizes
id: build
- name: Run forge coverage
id: coverage
run: |
{
echo 'COVERAGE<<EOF'
forge coverage | grep '^|' | grep -v 'test/'
echo EOF
} >> "$GITHUB_OUTPUT"
env:
FOUNDRY_RPC_URL: "${{ secrets.RPC_URL }}"

- name: Check coverage is updated
uses: actions/github-script@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const file = "coverage.txt"
if(!fs.existsSync(file)) {
console.log("Nothing to check");
return
}
const currentCoverage = fs.readFileSync(file, "utf8").trim();
const newCoverage = (`${{ steps.coverage.outputs.COVERAGE }}`).trim();
if (newCoverage != currentCoverage) {
core.setFailed(`Code coverage not updated. Run : forge coverage | grep '^|' | grep -v 'test/' > coverage.txt`);
}

- name: Comment on PR
id: comment
uses: actions/github-script@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const {data: comments} = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
})

const botComment = comments.find(comment => comment.user.id === 41898282)

const output = `${{ steps.coverage.outputs.COVERAGE }}`;
const commentBody = `Forge code coverage:\n${output}\n`;

if (botComment) {
github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: commentBody
})
} else {
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody
});
}
42 changes: 42 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Docker

on: [push]

jobs:
docker:
name: Build Docker Image
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: |
europe-west4-docker.pkg.dev/stakewiselabs/public/multichain
flavor: |
latest=auto
tags: |
type=ref,event=branch
type=ref,event=tag
type=sha
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GAR
uses: docker/login-action@v3
with:
registry: europe-west4-docker.pkg.dev
username: _json_key
password: ${{ secrets.GAR_JSON_KEY }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: deploy
file: deploy/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
21 changes: 21 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Lint

on:
push:

jobs:
run-linters:
name: Run linters
runs-on: ubuntu-latest

steps:
- name: Check out Git repository
uses: actions/checkout@v3

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Lint
run: forge fmt --check
34 changes: 0 additions & 34 deletions .github/workflows/test.yml

This file was deleted.

27 changes: 27 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Tests

on:
push:

jobs:
forge-tests:
name: Forge Tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Build
run: forge build

- name: Run tests
run: forge test --isolate -vvv
env:
FORGE_SNAPSHOT_CHECK: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Compiler files
cache/
out/
*venv/

# Ignores development broadcast logs
!/broadcast
Expand Down
7 changes: 7 additions & 0 deletions deploy/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
MAINNET_RPC_URL=https://example.com
TARGET_RPC_URL=https://example.com
PRIVATE_KEY=0x2......
TARGET_CHAIN=23
TARGET_ADDRESS=0xbd335c16c94be8c4dd073ae376ddf78bec1858df
PRICE_FEED=0xba74737a078c05500dd98c970909e4a3b90c35c6
PRICE_FEED_SENDER=0xf7d4e7273e5015c96728a6b02f31c505ee184603
11 changes: 11 additions & 0 deletions deploy/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM python:3.11-alpine

WORKDIR /app

COPY requirements.txt .

RUN pip install -r requirements.txt

COPY update_price.py .

ENTRYPOINT ["python", "update_price.py"]
19 changes: 19 additions & 0 deletions deploy/manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: multichain-price-update
spec:
schedule: "00 */6 * * *"
jobTemplate:
spec:
backoffLimit: 4
template:
spec:
containers:
- name: update
image: europe-west4-docker.pkg.dev/stakewiselabs/public/multichain:latest
imagePullPolicy: Always
envFrom:
- configMapRef:
name: multichain-config
restartPolicy: OnFailure
39 changes: 39 additions & 0 deletions deploy/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
aiohttp==3.9.5
aiosignal==1.3.1
attrs==23.2.0
bitarray==2.9.2
certifi==2024.2.2
charset-normalizer==3.3.2
ckzg==1.0.2
cytoolz==0.12.3
eth-account==0.11.2
eth-hash==0.7.0
eth-keyfile==0.8.1
eth-keys==0.5.1
eth-rlp==1.0.1
eth-typing==4.2.3
eth-utils==4.1.1
eth_abi==5.1.0
frozenlist==1.4.1
hexbytes==0.3.1
idna==3.7
jsonschema==4.22.0
jsonschema-specifications==2023.12.1
lru-dict==1.2.0
multidict==6.0.5
parsimonious==0.10.0
protobuf==5.27.0
pycryptodome==3.20.0
python-dotenv==1.0.1
pyunormalize==15.1.0
referencing==0.35.1
regex==2024.5.15
requests==2.32.2
rlp==4.0.1
rpds-py==0.18.1
toolz==0.12.1
typing_extensions==4.12.0
urllib3==2.2.1
web3==6.19.0
websockets==12.0
yarl==1.9.4
Loading
Loading