Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

chore: merge topos-smart-contracts into topos #475

Draft
wants to merge 25 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
95ab265
chore: current
hadjiszs Mar 6, 2024
d049bb6
chore: tmp
hadjiszs Mar 8, 2024
d419c62
fix: default working dirs for contract workflows
JDawg287 Mar 12, 2024
e5b1791
chore: rename workflow for clarity
JDawg287 Mar 12, 2024
d56c7ce
chore: remove redundant workflow
JDawg287 Mar 12, 2024
05fb704
feat: add npm cache dependency path
JDawg287 Mar 12, 2024
413da16
feat: test
JDawg287 Mar 12, 2024
543caab
fix: contracts analyze
JDawg287 Mar 12, 2024
88d0b26
feat: modify sequencer dependency path to local contracts
JDawg287 Mar 13, 2024
16a96c4
chore: unify docker images
JDawg287 Mar 13, 2024
7052ca3
feat: add build script for topos-sequencer-subnet-client
JDawg287 Mar 13, 2024
3f3964d
chore: revert Dockerfile
JDawg287 Mar 14, 2024
24f39d0
fix: remove unnecessary
JDawg287 Mar 14, 2024
005b4ae
feat: optional build flag for sequencer build script
JDawg287 Mar 14, 2024
82bffee
fix: docker build
JDawg287 Mar 14, 2024
73629a3
feat: reinstate contracts Docker build push
JDawg287 Mar 18, 2024
4715996
fix: remove contracts from topos Docker image
JDawg287 Mar 18, 2024
cf71438
fix: add missing from revert
JDawg287 Mar 18, 2024
16ebfbf
fix: readme
JDawg287 Mar 27, 2024
fdbf159
chore: update from upstream
JDawg287 Mar 27, 2024
769d3c6
fix: contracts docker build push workflow
JDawg287 Mar 27, 2024
9742b84
feat: link contracts to the topos repo
JDawg287 Mar 28, 2024
ea49174
fix: contracts image name
JDawg287 Mar 28, 2024
c1bc681
fix: update docker image name
JDawg287 Mar 28, 2024
10754d0
chore: revert label
JDawg287 Mar 28, 2024
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
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,12 @@
!tools/config/nextest.toml
!.git

# Allow contract related code
!contracts/contracts/**/*
!contracts/hardhat.config.ts
!contracts/package*.json
!contracts/scripts/**/*
!contracts/tsconfig.json
!contracts/typechain-types/**/*

!LICENSE
20 changes: 20 additions & 0 deletions .github/workflows/contract-analyze.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Contracts - Analyze

on:
push:
branches: 'feat/TP-888'
pull_request:
workflow_dispatch:

jobs:
lint:
name: Analyze
runs-on: ubuntu-latest-16-core

steps:
- uses: actions/checkout@v3
- uses: crytic/[email protected]
with:
node-version: 16
target: ./contracts
slither-config: ./contracts/slither.config.json
27 changes: 27 additions & 0 deletions .github/workflows/contract-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Contracts - Build

on:
push:
branches: 'feat/TP-888'
pull_request:
workflow_dispatch:

jobs:
build:
name: Build
runs-on: ubuntu-latest-16-core
defaults:
run:
working-directory: ./contracts/

steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'
cache-dependency-path: ./contracts/package-lock.json

- run: npm ci
- run: npm run build
38 changes: 38 additions & 0 deletions .github/workflows/contract-docker-build-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Contracts_docker_build_push

on:
push:
branches: feat/TP-888
pull_request:
release:
types: [created]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
docker:
uses: ./.github/workflows/contract-docker-utils.yml
e2e:
needs: docker
if: ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-latest-16-core
steps:
- name: Set environment
run: |
# It's fine to assume a single tag. Our tagging strategy follows a 1:1 mapping of image:tag
tags=${{ needs.docker.outputs.tags }}
echo "docker_tag=${tags#*:}" >> $GITHUB_ENV
shell: bash

- uses: convictional/[email protected]
with:
owner: topos-protocol
repo: e2e-tests
github_token: ${{ secrets.ROBOT_PAT_TRIGGER_E2E_WORKFLOWS }}
workflow_file_name: frontend:erc20-messaging.yml
ref: main
wait_interval: 60
client_payload: '{ "topos-smart-contracts-docker-tag": "${{ env.docker_tag }}" }'
61 changes: 61 additions & 0 deletions .github/workflows/contract-docker-utils.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Contracts - Docker template

on:
workflow_call:
outputs:
tags:
description: 'Docker tags'
value: ${{ jobs.docker.outputs.tags }}

env:
REGISTRY: ghcr.io
IMAGE_NAME: topos-contracts

jobs:
docker:
runs-on: ubuntu-latest-16-core
outputs:
tags: ${{ steps.meta.outputs.tags }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v4
with:
short-length: 7

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_URL }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=raw,value=test,enable={{is_default_branch}}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}

- name: Push to GitHub Container Registry
uses: docker/build-push-action@v3
with:
context: ./contracts
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: |
type=registry,ref=${{ env.REGISTRY }}/${{ github.repository }}:build-cache-${{ env.GITHUB_REF_SLUG_URL }}-${{ github.workflow }}
type=registry,ref=${{ env.REGISTRY }}/${{ github.repository }}:build-cache-main-${{ github.workflow }}
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ github.repository }}:build-cache-${{ env.GITHUB_REF_SLUG_URL }}-${{ github.workflow }},mode=max
27 changes: 27 additions & 0 deletions .github/workflows/contract-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Contracts - Format

on:
push:
branches: 'feat/TP-888'
pull_request:
workflow_dispatch:

jobs:
format:
name: Format
runs-on: ubuntu-latest-16-core
defaults:
run:
working-directory: ./contracts/

steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'
cache-dependency-path: ./contracts/package-lock.json

- run: npm ci
- run: npm run format
27 changes: 27 additions & 0 deletions .github/workflows/contract-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Contracts - Lint

on:
push:
branches: 'feat/TP-888'
pull_request:
workflow_dispatch:

jobs:
lint:
name: Lint
runs-on: ubuntu-latest-16-core
defaults:
run:
working-directory: ./contracts/

steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'
cache-dependency-path: ./contracts/package-lock.json

- run: npm ci
- run: npm run lint
22 changes: 22 additions & 0 deletions .github/workflows/contract-npm-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Contracts - Publish Package to NPM Registry
on:
release:
types: [published]
jobs:
npm-package:
runs-on: ubuntu-latest-16-core
defaults:
run:
working-directory: ./contracts
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
scope: '@topos-protocol'
- run: npm ci
- run: npm run build
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
27 changes: 27 additions & 0 deletions .github/workflows/contract-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Contracts - Test

on:
push:
branches: 'feat/TP-888'
pull_request:
workflow_dispatch:

jobs:
test:
name: Test
runs-on: ubuntu-latest-16-core
defaults:
run:
working-directory: ./contracts

steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'
cache-dependency-path: ./contracts/package-lock.json

- run: npm ci
- run: npm run test
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Coverage
name: Topos - Coverage

on:
push:
branches:
- main
- feat/TP-888
paths: crates/**
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Build and host documentation on GH pages
name: Topos - Build and host documentation on GH pages
on:
push:
branches:
- main
- feat/TP-888

jobs:
build:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Docker build and push
name: Topos - Docker build and push

on:
push:
branches: [main, debug/**]
branches: [main, debug/**, feat/TP-888]
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
release:
Expand All @@ -14,7 +14,7 @@ concurrency:

jobs:
docker:
uses: ./.github/workflows/docker_utils.yml
uses: ./.github/workflows/topos-docker-utils.yml
secrets: inherit

integration-erc20-e2e:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: template - docker
name: Topos - Docker template

env:
REGISTRY: ghcr.io
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Checking PR semantic
name: Topos - Checking PR semantic

on:
pull_request_target:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Quality
name: Topos - Quality

on:
push:
branches:
- main
- feat/TP-888
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
workflow_dispatch:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Release
name: Topos - Release

on:
release:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Sequencer Topos Core Contract interaction test
name: Topos - Sequencer Topos Core Contract interaction test

on:
push:
branches: [main]
branches: [main, feat/TP-888]
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
workflow_dispatch:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Test
name: Topos - Test

on:
push:
branches:
- main
- feat/TP-888
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

Expand Down
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
ARG RUSTUP_TOOLCHAIN=stable

FROM node:18.15.0-slim as topos-contracts

WORKDIR /usr/src/app

COPY ./contracts/package*.json .
RUN npm install

COPY ./contracts .

RUN npm run build

FROM --platform=${BUILDPLATFORM:-linux/amd64} ghcr.io/topos-protocol/rust_builder:bullseye-${RUSTUP_TOOLCHAIN} AS base

ARG FEATURES
Expand All @@ -8,11 +20,13 @@ ARG SCCACHE_BUCKET
ARG SCCACHE_REGION
ARG RUSTC_WRAPPER
ARG PROTOC_VERSION=22.2
ARG SKIP_CONTRACT_BUILD=true

WORKDIR /usr/src/app

FROM --platform=${BUILDPLATFORM:-linux/amd64} base AS build
COPY . .
COPY --from=topos-contracts /usr/src/app/artifacts ./contracts/artifacts
RUN --mount=type=secret,id=aws,target=/root/.aws/credentials \
--mount=type=cache,id=sccache,target=/root/.cache/sccache \
cargo build --release --no-default-features --features=${FEATURES} \
Expand Down
Loading
Loading