Skip to content

Commit

Permalink
Merge branch 'master' into feature/forking
Browse files Browse the repository at this point in the history
  • Loading branch information
error2215 authored Feb 6, 2024
2 parents 5f8ad38 + a38366a commit 52d7230
Show file tree
Hide file tree
Showing 132 changed files with 242 additions and 512 deletions.
257 changes: 53 additions & 204 deletions .github/workflows/cross-platform.yml
Original file line number Diff line number Diff line change
@@ -1,205 +1,54 @@
on:
workflow_dispatch:
workflow_call:

name: cross-platform

env:
CARGO_TERM_COLOR: always

on: push
name: foxar pipeline
jobs:
build-tests:
name: building ${{ matrix.job.target }} (${{ matrix.job.os }}) / ${{ matrix.archive.name }}
runs-on: ${{ matrix.job.os }}
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
archive:
- name: unit-tests
file: nextest-unit.tar.zst
flags: --workspace --all-features --lib --bins
- name: integration-tests
file: nextest-integration.tar.zst
flags: --workspace
job:
# The OS is used for the runner
# The target is used by Cargo
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
- os: macos-latest
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc

steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.job.target }}
- uses: Swatinem/rust-cache@v2
- name: Install nextest
uses: taiki-e/install-action@nextest

# Required for spark commands that use git
- name: Setup git
run: |
git config --global user.name "GitHub Actions Bot"
git config --global user.email "<>"
- name: Apple M1 setup
if: ${{ matrix.job.target == 'aarch64-apple-darwin' }}
run: |
echo "SDKROOT=$(xcrun -sdk macosx --show-sdk-path)" >> $GITHUB_ENV
echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-platform-version)" >> $GITHUB_ENV
- name: Linux ARM setup
if: ${{ matrix.job.target == 'aarch64-unknown-linux-gnu' }}
run: |
sudo apt-get update -y
sudo apt-get install -y gcc-aarch64-linux-gnu
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
# For some reason the FFI cheatcode uses WSL bash instead of Git bash, so we need to install a WSL distribution
- name: Windows setup
if: ${{ matrix.job.target == 'x86_64-pc-windows-msvc' }}
uses: Vampire/setup-wsl@v1
with:
distribution: Ubuntu-20.04
set-as-default: true

- name: Build archive (unit tests)
run: |
cargo nextest archive \
--locked ${{ matrix.job.flags }} \
--archive-file ${{ matrix.job.target }}-${{ matrix.archive.file }}
- name: Upload archive
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.job.target }}-${{ matrix.archive.name }}
path: ${{ matrix.job.target }}-${{ matrix.archive.file }}

unit:
name: unit tests ${{ matrix.job.target }} (${{ matrix.job.os }}) / ${{ matrix.archive.name }} / ${{ matrix.nextest.name }}
runs-on: ${{ matrix.job.os }}
needs: build-tests
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
archive:
- name: unit-tests
file: nextest-unit.tar.zst
job:
# The OS is used for the runner
# The target is used by Cargo
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
- os: macos-latest
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
nextest:
- name: non-forking
filter: "!test(~fork) & !test(~live) & !test(~spark_std) & !test(~deploy_and_simulate)"
env:
ETH_RPC_URL: https://eth-mainnet.alchemyapi.io/v2/C3JEvfW6VgtqZQa-Qp1E-2srEiIc02sD
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.job.target }}
- uses: taiki-e/install-action@nextest
- name: Download archives
uses: actions/download-artifact@v3
with:
name: ${{ matrix.job.target }}-${{ matrix.archive.name }}
- name: Setup git config
run: |
git config --global user.name "GitHub Actions Bot"
git config --global user.email "<>"
- name: cargo nextest
shell: bash
run: |
# see https://github.com/foxar-rs/foxar/pull/3959
export LD_LIBRARY_PATH="$(rustc --print sysroot)/lib"
cargo nextest run --retries 3 --archive-file ${{ matrix.job.target }}-${{ matrix.archive.file }} -E '${{ matrix.nextest.filter }}'
integration:
name:
integration tests ${{ matrix.job.target }} (${{ matrix.job.os }}) / ${{
matrix.archive.name }} / ${{ matrix.nextest.name }}
runs-on: ${{ matrix.job.os }}
timeout-minutes: 60
needs: build-tests
strategy:
fail-fast: false
matrix:
archive:
- name: integration-tests
file: nextest-integration.tar.zst
job:
# The OS is used for the runner
# The target is used by Cargo
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
- os: macos-latest
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
nextest:
- name: non-forking
# skip fork,verify,forge-std and script tests that use heavy simulation
filter: "!test(~fork) & !test(~live) & !test(~spark_std) & !test(~deploy_and_simulate)"
# the aarch64-apple-darwin runner is particularly slow with script related tests
macos-aarch-filter: "!test(~fork) & !test(~live) & !test(~spark_std) & !test(~deploy_)"
env:
ETH_RPC_URL: https://eth-mainnet.alchemyapi.io/v2/C3JEvfW6VgtqZQa-Qp1E-2srEiIc02sD
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@nextest
- name: Download archives
uses: actions/download-artifact@v3
with:
name: ${{ matrix.job.target }}-${{ matrix.archive.name }}

- name: Forge RPC cache
uses: actions/cache@v3
if: matrix.nextest.name != 'non-forking'
with:
path: "$HOME/.foxar/cache"
key: rpc-cache-${{ hashFiles('cli/tests/rpc-cache-keyfile') }}
- name: Setup git config
run: |
git config --global user.name "GitHub Actions Bot"
git config --global user.email "<>"
- name: cargo nextest
if: ${{ matrix.job.target == 'aarch64-apple-darwin' }}
shell: bash
run: |
# see https://github.com/foxar-rs/foxar/pull/3959
export LD_LIBRARY_PATH="$(rustc --print sysroot)/lib"
cargo nextest run --retries 3 --archive-file ${{ matrix.job.target }}-${{ matrix.archive.file }} -E '${{ matrix.nextest.macos-aarch-filter }}'
- name: cargo nextest
if: ${{ matrix.job.target != 'aarch64-apple-darwin' }}
shell: bash
run: |
# see https://github.com/foxar-rs/foxar/pull/3959
export LD_LIBRARY_PATH="$(rustc --print sysroot)/lib"
cargo nextest run --retries 3 --archive-file ${{ matrix.job.target }}-${{ matrix.archive.file }} -E '${{ matrix.nextest.filter }}'
tests:
name: build ${{ matrix.job.target }} (${{ matrix.job.os }})
runs-on: ${{ matrix.job.os }}
strategy:
matrix:
job:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
- os: macos-latest
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.job.target }}
- name: Git
run: |
git config --global user.name "GitHub Actions Bot"
git config --global user.email "<>"
- name: Apple M1 setup
if: ${{ matrix.job.target == 'aarch64-apple-darwin' }}
run: |
echo "SDKROOT=$(xcrun -sdk macosx --show-sdk-path)" >> $GITHUB_ENV
echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-platform-version)" >> $GITHUB_ENV
- name: Linux ARM setup
if: ${{ matrix.job.target == 'aarch64-unknown-linux-gnu' }}
run: |
sudo apt-get update -y
sudo apt-get install -y gcc-aarch64-linux-gnu
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
# For some reason the FFI cheatcode uses WSL bash instead of Git bash, so we need to install a WSL distribution
- name: Windows setup
if: ${{ matrix.job.target == 'x86_64-pc-windows-msvc' }}
uses: Vampire/setup-wsl@v1
with:
distribution: Ubuntu-20.04
set-as-default: true
- name: Cache
uses: Swatinem/rust-cache@v2
- name: Test
run: cargo test --all --all-features
- name: Build
run: cargo build
39 changes: 3 additions & 36 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -1,87 +1,54 @@
name: Build and Publish Docker

name: Docker
on:
push:
tags:
- "v*.*.*"
schedule:
- cron: "0 0 * * *"
# Trigger without any parameters a proactive rebuild
workflow_dispatch: {}
workflow_call:

env:
REGISTRY: ghcr.io
# Will resolve to foxar-rs/foxar
IMAGE_NAME: ${{ github.repository }}

jobs:
container:
runs-on: ubuntu-20.04
# https://docs.github.com/en/actions/reference/authentication-in-a-workflow
runs-on: ubuntu-latest
permissions:
id-token: write
packages: write
contents: read
timeout-minutes: 60

steps:
- name: Checkout repository
id: checkout
uses: actions/checkout@v3

- name: Install Docker BuildX
uses: docker/setup-buildx-action@v2
id: buildx
with:
install: true

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
# Ensure this doesn't trigger on PR's
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

# Creates an additional 'latest' or 'nightly' tag
# If the job is triggered via cron schedule, tag nightly and nightly-{SHA}
# If the job is triggered via workflow dispatch and on a master branch, tag branch and latest
# Otherwise, just tag as the branch name
- name: Finalize Docker Metadata
id: docker_tagging
run: |
if [[ "${{ github.event_name }}" == 'schedule' ]]; then
echo "cron trigger, assigning nightly tag"
echo "::set-output name=docker_tags::${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly-${GITHUB_SHA}"
elif [[ "${GITHUB_REF##*/}" == "main" ]] || [[ ${GITHUB_REF##*/} == "master" ]]; then
echo "manual trigger from master/main branch, assigning latest tag"
if [[ "${GITHUB_REF##*/}" == "main" ]] || [[ ${GITHUB_REF##*/} == "master" ]]; then
echo "::set-output name=docker_tags::${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${GITHUB_REF##*/},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest"
else
echo "Neither scheduled nor manual release from main branch. Just tagging as branch name"
echo "::set-output name=docker_tags::${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${GITHUB_REF##*/}"
fi
# Log docker metadata to explicitly know what is being pushed
- name: Inspect Docker Metadata
run: |
echo "TAGS -> ${{ steps.docker_tagging.outputs.docker_tags }}"
echo "LABELS -> ${{ steps.meta.outputs.labels }}"
# Build and push Docker image
# https://github.com/docker/build-push-action
# https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
Expand Down
Loading

0 comments on commit 52d7230

Please sign in to comment.