Skip to content
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
60 changes: 60 additions & 0 deletions .github/workflows/bridge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Bridge

on:
push:
branches:
- main
- staging
paths:
- 'bridge/**'
- '.github/workflows/bridge.yml'
pull_request:
branches:
- main
- staging
paths:
- 'bridge/**'
- '.github/workflows/bridge.yml'

defaults:
run:
working-directory: 'bridge'

jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.18.x
- name: Checkout code
uses: actions/checkout@v2
- name: Install Solc
uses: pontem-network/get-solc@master
- name: Install Geth Tools
uses: gacts/install-geth-tools@v1
- name: Lint
run: |
rm -rf $HOME/.cache/golangci-lint
make mock_abi
make lint
goimports-lint:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.18.x
- name: Checkout code
uses: actions/checkout@v2
- name: Install goimports
run: go install golang.org/x/tools/cmd/goimports
- run: goimports -local scroll-tech/bridge/ -w .
- run: go mod tidy
# If there are any diffs from goimports or go mod tidy, fail.
- name: Verify no changes from goimports and go mod tidy
run: |
if [ -n "$(git status --porcelain)" ]; then
exit 1
fi
55 changes: 55 additions & 0 deletions .github/workflows/common.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Common

on:
push:
branches:
- main
- staging
paths:
- 'common/**'
- '.github/workflows/common.yml'
pull_request:
branches:
- main
- staging
paths:
- 'common/**'
- '.github/workflows/common.yml'

defaults:
run:
working-directory: 'common'

jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.18.x
- name: Checkout code
uses: actions/checkout@v2
- name: Lint
run: |
rm -rf $HOME/.cache/golangci-lint
make lint
goimports-lint:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.18.x
- name: Checkout code
uses: actions/checkout@v2
- name: Install goimports
run: go install golang.org/x/tools/cmd/goimports
- run: goimports -local scroll-tech/common/ -w .
- run: go mod tidy
# If there are any diffs from goimports or go mod tidy, fail.
- name: Verify no changes from goimports and go mod tidy
run: |
if [ -n "$(git status --porcelain)" ]; then
exit 1
fi
55 changes: 55 additions & 0 deletions .github/workflows/coordinator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Coordinator

on:
push:
branches:
- main
- staging
paths:
- 'coordinator/**'
- '.github/workflows/coordinator.yml'
pull_request:
branches:
- main
- staging
paths:
- 'coordinator/**'
- '.github/workflows/coordinator.yml'

defaults:
run:
working-directory: 'coordinator'

jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.18.x
- name: Checkout code
uses: actions/checkout@v2
- name: Lint
run: |
rm -rf $HOME/.cache/golangci-lint
make lint
goimports-lint:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.18.x
- name: Checkout code
uses: actions/checkout@v2
- name: Install goimports
run: go install golang.org/x/tools/cmd/goimports
- run: goimports -local scroll-tech/coordinator/ -w .
- run: go mod tidy
# If there are any diffs from goimports or go mod tidy, fail.
- name: Verify no changes from goimports and go mod tidy
run: |
if [ -n "$(git status --porcelain)" ]; then
exit 1
fi
55 changes: 55 additions & 0 deletions .github/workflows/database.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Database

on:
push:
branches:
- main
- staging
paths:
- 'database/**'
- '.github/workflows/database.yml'
pull_request:
branches:
- main
- staging
paths:
- 'database/**'
- '.github/workflows/database.yml'

defaults:
run:
working-directory: 'database'

jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.18.x
- name: Checkout code
uses: actions/checkout@v2
- name: Lint
run: |
rm -rf $HOME/.cache/golangci-lint
make lint
goimports-lint:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.18.x
- name: Checkout code
uses: actions/checkout@v2
- name: Install goimports
run: go install golang.org/x/tools/cmd/goimports
- run: goimports -local scroll-tech/database/ -w .
- run: go mod tidy
# If there are any diffs from goimports or go mod tidy, fail.
- name: Verify no changes from goimports and go mod tidy
run: |
if [ -n "$(git status --porcelain)" ]; then
exit 1
fi
8 changes: 4 additions & 4 deletions .github/workflows/roller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.17.x
go-version: 1.18.x
- name: Checkout code
uses: actions/checkout@v2
- name: Cache cargo registry
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.17.x
go-version: 1.18.x
- name: Checkout code
uses: actions/checkout@v2
- name: Lint
Expand All @@ -73,11 +73,11 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.17.x
go-version: 1.18.x
- name: Checkout code
uses: actions/checkout@v2
- name: Install goimports
run: go get golang.org/x/tools/cmd/goimports
run: go install golang.org/x/tools/cmd/goimports
- run: goimports -local scroll-tech/go-roller/ -w .
- run: go mod tidy
# If there are any diffs from goimports or go mod tidy, fail.
Expand Down
95 changes: 95 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
imagePrefix = 'scrolltech'
credentialDocker = 'dockerhub'

def boolean test_result = false

pipeline {
agent any
options {
timeout (20)
}
tools {
go 'go-1.18'
}
environment {
GO111MODULE = 'on'
}
stages {
stage('Build') {
when {
anyOf { changeset "bridge/**"; changeset "build/**"; changeset "coordinator/**"; changeset "common/**"; changeset "database/**" }
}
steps {
//start to build project
sh '''#!/bin/bash
export PATH=/home/ubuntu/go/bin:$PATH
make -C bridge mock_abi
make -C bridge bridge
make -C bridge docker
make -C coordinator coordinator
make -C coordinator docker
'''
}
}
stage('Test') {
when {
anyOf { changeset "bridge/**"; changeset "build/**"; changeset "coordinator/**"; changeset "common/**"; changeset "database/**" }
}
steps {
sh "docker ps -aq | xargs -r docker stop"
sh "docker container prune -f"
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
sh '''
cd ./bridge
go test -v -race -coverprofile=coverage.txt -covermode=atomic -p 1 scroll-tech/database
go test -v -race -coverprofile=coverage.txt -covermode=atomic -p 1 scroll-tech/database/migrate
go test -v -race -coverprofile=coverage.txt -covermode=atomic -p 1 scroll-tech/database/docker
go test -v -race -coverprofile=coverage.txt -covermode=atomic -p 1 scroll-tech/bridge/abi
go test -v -race -coverprofile=coverage.txt -covermode=atomic -p 1 scroll-tech/bridge/l1
go test -v -race -coverprofile=coverage.txt -covermode=atomic -p 1 scroll-tech/bridge/l2
go test -v -race -coverprofile=coverage.txt -covermode=atomic -p 1 scroll-tech/bridge/sender
go test -v -race -coverprofile=coverage.txt -covermode=atomic -p 1 scroll-tech/common/docker
go test -v -race -coverprofile=coverage.txt -covermode=atomic -p 1 scroll-tech/coordinator
go test -v -race -coverprofile=coverage.txt -covermode=atomic -p 1 scroll-tech/coordinator/verifier
cd ..
'''
script {
for (i in ['bridge', 'coordinator', 'database']) {
sh "cd $i && go test -v -race -coverprofile=coverage.txt -covermode=atomic \$(go list ./... | grep -v 'database\\|l2\\|l1\\|common\\|coordinator')"
}
}

script { test_result = true }
}
}
}
stage('Docker') {
when {
anyOf { changeset "bridge/**"; changeset "build/**"; changeset "coordinator/**"; changeset "common/**"; changeset "database/**" }
}
steps {
withCredentials([usernamePassword(credentialsId: "${credentialDocker}", passwordVariable: 'dockerPassword', usernameVariable: 'dockerUser')]) {
script {
if (test_result == true) {
sh 'docker login --username=${dockerUser} --password=${dockerPassword}'
for (i in ['bridge', 'coordinator']) {
sh "docker build -t ${imagePrefix}/$i:${GIT_COMMIT} -f $i/Dockerfile ."
sh "docker tag ${imagePrefix}/$i:${GIT_COMMIT} ${imagePrefix}/$i:latest"
sh "docker push ${imagePrefix}/$i:${GIT_COMMIT}"
sh "docker push ${imagePrefix}/$i:latest"
sh "docker rmi ${imagePrefix}/$i:${GIT_COMMIT}"
sh "docker rmi ${imagePrefix}/$i:latest"
}
}
}
}
}
}
}
post {
always {
cleanWs()
slackSend(message: "${JOB_BASE_NAME} ${GIT_COMMIT} #${BUILD_NUMBER} deploy ${currentBuild.result}")
}
}
}
3 changes: 3 additions & 0 deletions bridge/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/build/bin
.idea
contracts
14 changes: 14 additions & 0 deletions bridge/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Build bridge in a stock Go builder container
FROM scrolltech/go-builder:1.18 as builder

COPY ./ /

RUN cd /bridge/cmd && go build -v -p 4 -o bridge

# Pull bridge into a second stage deploy alpine container
FROM alpine:latest

COPY --from=builder /bridge/cmd /bin/

EXPOSE 8645
ENTRYPOINT ["bridge"]
Loading