Skip to content

Commit

Permalink
Merge pull request #1 from EspressoSystems/fix/own-repo
Browse files Browse the repository at this point in the history
Copy and modify config files to make it works
  • Loading branch information
ImJeremyHe committed Oct 6, 2023
2 parents 1e5edfb + 847e94a commit d84bfac
Show file tree
Hide file tree
Showing 32 changed files with 13,731 additions and 32 deletions.
26 changes: 26 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Environment for local demo network.
# This file is meant to work with docker-compose.yaml

RUST_LOG=info,libp2p=off
RUST_LOG_FORMAT=full

L1_BLOCK_TIME_SEC=3

# Internal port inside container
ESPRESSO_SEQUENCER_URL=http://sequencer0:50000

# Example rollup demo variables
ESPRESSO_DEMO_ROLLUP_PORT=8084
ESPRESSO_DEMO_L1_HTTP_PROVIDER=http://demo-l1-network:8545
ESPRESSO_DEMO_L1_WS_PROVIDER=ws://demo-l1-network:8546
ESPRESSO_DEMO_HOTSHOT_ADDRESS=0x0116686e2291dbd5e317f47fadbfb43b599786ef
ESPRESSO_DEMO_ROLLUP_MNEMONIC="test test test test test test test test test test test junk"
ESPRESSO_DEMO_ROLLUP_ACCOUNT_INDEX=7

# Foundry
# The mnemonic used by foundry to deploy contracts.
MNEMONIC="test test test test test test test test test test test junk"
# The RPC URL for deploying to the sepolia network.
SEPOLIA_RPC_URL=
# The etherscan API key is needed to verify contracts on etherscan.
ETHERSCAN_API_KEY=
50 changes: 50 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build

on:
push:
branches:
- main
- release-*
tags:
# YYYYMMDD
- "20[0-9][0-9][0-1][0-9][0-3][0-9]*"
pull_request:
branches:
workflow_dispatch:

env:
RUSTFLAGS: "--cfg async_executor_impl=\"async-std\" --cfg async_channel_impl=\"async-std\""
RUST_LOG: info,libp2p=off,node=error

jobs:
build:
runs-on: self-hosted
container:
image: ghcr.io/espressosystems/devops-rust:stable
steps:
- uses: styfle/cancel-workflow-action@0.11.0
name: Cancel Outdated Builds
with:
all_but_latest: true
access_token: ${{ github.token }}

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

- uses: actions/checkout@v4
name: Checkout Repository
with:
submodules: true

- uses: Swatinem/rust-cache@v2
name: Enable Rust Caching

- name: Build
run: |
cargo build --release --workspace
- name: Test
run: |
cargo test --release --workspace --all-features --no-run
cargo test --release --workspace --all-features --verbose -- --test-threads 1 --nocapture
timeout-minutes: 30
121 changes: 121 additions & 0 deletions .github/workflows/build_static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: Static Build
on:
push:
branches:
- main
- release-*
tags:
# YYYYMMDD
- "20[0-9][0-9][0-1][0-9][0-3][0-9]*"
schedule:
- cron: "0 0 * * 1"
pull_request:
workflow_dispatch:

jobs:
static-build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
arch:
- amd
- arm
steps:
- name: Prepare AMD
if: ${{ matrix.arch == 'amd' }}
run: |
echo "TARGET=x86_64-unknown-linux-musl" >> $GITHUB_ENV
echo "DEVSHELL=.#crossShell" >> $GITHUB_ENV
- name: Prepare ARM
if: ${{ matrix.arch == 'arm' }}
run: |
echo "TARGET=aarch64-unknown-linux-musl" >> $GITHUB_ENV
echo "DEVSHELL=.#armCrossShell" >> $GITHUB_ENV
- name: Checkout Repository
uses: actions/checkout@v4

- name: Install Nix
uses: cachix/install-nix-action@v23

- uses: cachix/cachix-action@v12
# If PR is from a non-collaborator (e. g. dependabot) the secrets are missing and the login to cachix fails.
continue-on-error: true
with:
name: espresso-systems-private
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
extraPullNames: nix-community

- name: Cache cargo
uses: actions/cache@v3.3.2
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git
target
key: espresso-sequencer-static-${{matrix.arch}}-v0-${{ hashFiles('Cargo.lock') }}

- name: Fix Git Security Issue
run: git config --global --add safe.directory "$PWD"

- name: Compile all executables
# timeout-minutes: 120
run: |
nix develop $DEVSHELL --accept-flake-config --option sandbox relaxed -c cargo build --release
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ env.TARGET }}-services
path: |
target/${{ env.TARGET }}/release/example-l2
target/${{ env.TARGET }}/release/cli
static-dockers:
runs-on: ubuntu-latest
needs: static-build
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Download executables AMD
uses: actions/download-artifact@v3
with:
name: x86_64-unknown-linux-musl-services
path: target/amd64/release

- name: Download executables ARM
uses: actions/download-artifact@v3
with:
name: aarch64-unknown-linux-musl-services
path: target/arm64/release

- name: Setup Docker BuildKit (buildx)
uses: docker/setup-buildx-action@v2

- name: Login to Github Container Repo
uses: docker/login-action@v3
if: github.event_name != 'pull_request'
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Generate example rollup metadata
uses: docker/metadata-action@v5
id: example-rollup
with:
images: ghcr.io/espressosystems/espresso-sequencer/example-rollup

- name: Build and push example-rollup docker
uses: docker/build-push-action@v4
with:
context: ./
file: ./docker/example-rollup.Dockerfile
platforms: linux/amd64,arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.example-rollup.outputs.tags }}
labels: ${{ steps.example-rollup.outputs.labels }}
24 changes: 24 additions & 0 deletions .github/workflows/combine-prs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Combine PRs

on:
schedule:
- cron: "0 1 * * MON"
workflow_dispatch: # allows to manually trigger the workflow

# The minimum permissions required to run this Action
permissions:
contents: write
pull-requests: write
checks: read

jobs:
combine-prs:
runs-on: ubuntu-latest

steps:
- name: combine-prs
id: combine-prs
uses: github/combine-prs@v4.0.0
with:
github_token: ${{ github.token }}
labels: "dependabot,combined-pr"
42 changes: 42 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Lint

on:
push:
branches:
- main
- release-*
tags:
# YYYYMMDD
- "20[0-9][0-9][0-1][0-9][0-3][0-9]*"
pull_request:
branches:
workflow_dispatch:

env:
RUSTFLAGS: "--cfg async_executor_impl=\"async-std\" --cfg async_channel_impl=\"async-std\""
RUST_LOG: info,libp2p=off

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: styfle/cancel-workflow-action@0.11.0
name: Cancel Outdated Builds
with:
all_but_latest: true
access_token: ${{ github.token }}

- uses: actions/checkout@v4
name: Checkout Repository

- uses: Swatinem/rust-cache@v2
name: Enable Rust Caching

- name: Format Check
run: cargo fmt -- --check

- name: Check
run: cargo clippy --workspace --all-features --all-targets -- -D warnings

- name: Audit
run: cargo audit --ignore RUSTSEC-2023-0063 --ignore RUSTSEC-2023-0065
26 changes: 26 additions & 0 deletions .github/workflows/update_nix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: update-flake-lock

on:
workflow_dispatch: # allows manual triggering
schedule:
- cron: "0 0 * * 0" # runs weekly on Sunday at 00:00

jobs:
lockfile:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Nix
uses: cachix/install-nix-action@v23

- uses: cachix/cachix-action@v12
with:
name: espresso-systems-private
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"

- name: Update flake.lock
uses: DeterminateSystems/update-flake-lock@v20
with:
pr-title: "Weekly PR to bump flake.nix" # Title of PR to be created
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Cargo
# will have compiled files and executables
debug/
target/

# generated by nix-pre-commit-hooks
/.pre-commit-config.yaml

# Jetbrains editor
.idea

# vscode stuff
.vscode

cache/

node_modules/
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "contracts/lib/forge-std"]
path = contracts/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "contracts/lib/hotshot"]
path = contracts/lib/hotshot
url = https://github.com/EspressoSystems/espresso-sequencer
23 changes: 23 additions & 0 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"extends": "solhint:recommended",
"rules": {
"code-complexity": ["error", 8]
, "compiler-version": ["error", ">=0.8.0"]
, "const-name-snakecase": "error"
, "contract-name-camelcase": "error"
, "event-name-camelcase": "error"
, "func-name-mixedcase": "error"
, "func-param-name-mixedcase": "error"
, "func-visibility": ["error", { "ignoreConstructors": true }]
, "imports-on-top": "error"
, "max-line-length": ["error", 120]
, "modifier-name-mixedcase": "error"
, "named-parameters-mapping": "error"
, "no-console": "error"
, "no-empty-blocks": "error"
, "no-unused-vars": "error"
, "no-global-import": "off"
, "private-vars-leading-underscore": ["error", { "strict": true }]
, "var-name-mixedcase": "error"
}
}
Loading

0 comments on commit d84bfac

Please sign in to comment.