-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'mempool' into junderw/use-blocking-spawn
- Loading branch information
Showing
26 changed files
with
917 additions
and
11,769 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: CI Rust Setup | ||
description: 'Sets up the environment for Rust jobs during CI workflow' | ||
|
||
inputs: | ||
cache-name: | ||
description: 'Name of cache artifacts (same name is same cache key) empty to disable cache' | ||
required: false | ||
targets: | ||
description: 'A comma separated list of extra targets you want to install' | ||
required: false | ||
components: | ||
description: 'A comma separated list of extra components you want to install' | ||
required: false | ||
toolchain: | ||
description: 'The toolchain to use. If not specified, the rust-toolchain file will be used' | ||
required: false | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Get toolchain from input OR rust-toolchain file | ||
id: gettoolchain | ||
shell: bash | ||
run: |- | ||
RUST_TOOLCHAIN="${{ inputs.toolchain }}" | ||
if [ ! -f rust-toolchain ] && [ -z "${RUST_TOOLCHAIN}" ]; then | ||
echo "***ERROR*** NEED toolchain INPUT OR rust-toolchain FILE IN ROOT OF REPOSITORY" >&2 | ||
exit 1 | ||
fi | ||
if [ -z "${RUST_TOOLCHAIN}" ]; then | ||
RUST_TOOLCHAIN="$(cat rust-toolchain)" | ||
fi | ||
echo "toolchain=\"${RUST_TOOLCHAIN}\"" >> $GITHUB_OUTPUT | ||
- name: Install ${{ steps.gettoolchain.outputs.toolchain }} Rust toolchain | ||
id: toolchain | ||
# Commit date is Sep 19, 2023 | ||
uses: dtolnay/rust-toolchain@439cf607258077187679211f12aa6f19af4a0af7 | ||
with: | ||
toolchain: ${{ steps.gettoolchain.outputs.toolchain }} | ||
targets: ${{ inputs.targets }} | ||
components: ${{ inputs.components }} | ||
- name: Cache dependencies | ||
uses: actions/cache@v3 | ||
if: inputs.cache-name != '' | ||
with: | ||
path: | | ||
~/.cargo/registry | ||
~/.cargo/git | ||
target | ||
key: ${{ runner.os }}-cargo-${{ inputs.cache-name }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('**/Cargo.lock') }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,25 +13,19 @@ jobs: | |
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- id: toolchain | ||
uses: dtolnay/[email protected] | ||
- name: Cache dependencies | ||
uses: actions/cache@v3 | ||
- name: Setup Rust | ||
uses: './.github/actions/ci-rust-setup' | ||
with: | ||
path: | | ||
~/.cargo/registry | ||
~/.cargo/git | ||
target | ||
key: ${{ runner.os }}-cargo-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('**/Cargo.lock') }} | ||
cache-name: dev | ||
- run: cargo check --all-features | ||
|
||
fmt: | ||
name: Formatter | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- id: toolchain | ||
uses: dtolnay/rust-[email protected] | ||
- name: Setup Rust | ||
uses: './.github/actions/ci-rust-setup' | ||
with: | ||
components: rustfmt | ||
- run: cargo fmt --all -- --check | ||
|
@@ -41,17 +35,11 @@ jobs: | |
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- id: toolchain | ||
uses: dtolnay/[email protected] | ||
- name: Cache dependencies | ||
uses: actions/cache@v3 | ||
with: # test cache key is different (adding test cfg is a re-compile) | ||
path: | | ||
~/.cargo/registry | ||
~/.cargo/git | ||
target | ||
key: ${{ runner.os }}-cargo-test-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('**/Cargo.lock') }} | ||
- run: cargo test --package electrs --lib --all-features | ||
- name: Setup Rust | ||
uses: './.github/actions/ci-rust-setup' | ||
with: | ||
cache-name: test | ||
- run: cargo test --lib --all-features | ||
|
||
clippy: | ||
name: Linter | ||
|
@@ -67,17 +55,10 @@ jobs: | |
] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- id: toolchain | ||
uses: dtolnay/rust-[email protected] | ||
- name: Setup Rust | ||
uses: './.github/actions/ci-rust-setup' | ||
with: | ||
cache-name: dev | ||
components: clippy | ||
- name: Cache dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.cargo/registry | ||
~/.cargo/git | ||
target | ||
key: ${{ runner.os }}-cargo-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('**/Cargo.lock') }} | ||
- name: Clippy with Features = ${{ matrix.features }} | ||
run: cargo clippy ${{ matrix.features }} -- -D warnings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
name: Docker build on tag | ||
env: | ||
DOCKER_CLI_EXPERIMENTAL: enabled | ||
TAG_FMT: "^refs/tags/(((.?[0-9]+){3,4}))$" | ||
DOCKER_BUILDKIT: 0 | ||
COMPOSE_DOCKER_CLI_BUILD: 0 | ||
|
||
on: | ||
push: | ||
tags: | ||
- v[0-9]+.[0-9]+.[0-9]+ | ||
- v[0-9]+.[0-9]+.[0-9]+-* | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 120 | ||
name: Build and push to DockerHub | ||
steps: | ||
# Workaround based on JonasAlfredsson/[email protected] | ||
- name: Replace the current swap file | ||
shell: bash | ||
run: | | ||
sudo swapoff /mnt/swapfile | ||
sudo rm -v /mnt/swapfile | ||
sudo fallocate -l 13G /mnt/swapfile | ||
sudo chmod 600 /mnt/swapfile | ||
sudo mkswap /mnt/swapfile | ||
sudo swapon /mnt/swapfile | ||
- name: Show current memory and swap status | ||
shell: bash | ||
run: | | ||
sudo free -h | ||
echo | ||
sudo swapon --show | ||
- name: Mount a tmpfs over /var/lib/docker | ||
shell: bash | ||
run: | | ||
if [ ! -d "/var/lib/docker" ]; then | ||
echo "Directory '/var/lib/docker' not found" | ||
exit 1 | ||
fi | ||
sudo mount -t tmpfs -o size=10G tmpfs /var/lib/docker | ||
sudo systemctl restart docker | ||
sudo df -h | grep docker | ||
- name: Set env variables | ||
run: echo "TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV | ||
|
||
- name: Show set environment variables | ||
run: | | ||
printf " TAG: %s\n" "$TAG" | ||
- name: Add SHORT_SHA env property with commit short sha | ||
run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV | ||
|
||
- name: Login to Docker for building | ||
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin | ||
|
||
- name: Checkout project | ||
uses: actions/checkout@v3 | ||
|
||
# - name: Set up QEMU | ||
# uses: docker/setup-qemu-action@v3 | ||
# id: qemu | ||
|
||
- name: Setup Docker buildx action | ||
uses: docker/setup-buildx-action@v3 | ||
id: buildx | ||
|
||
- name: Available platforms | ||
run: echo ${{ steps.buildx.outputs.platforms }} | ||
|
||
- name: Cache Docker layers | ||
uses: actions/cache@v3 | ||
id: cache | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx | ||
restore-keys: | | ||
${{ runner.os }}-buildx | ||
- name: Run Docker buildx against tag | ||
run: | | ||
docker buildx build \ | ||
--cache-from "type=local,src=/tmp/.buildx-cache" \ | ||
--cache-to "type=local,dest=/tmp/.buildx-cache" \ | ||
--platform linux/amd64 \ | ||
--tag ${{ secrets.DOCKER_HUB_USER }}/electrs:$TAG \ | ||
--tag ${{ secrets.DOCKER_HUB_USER }}/electrs:latest \ | ||
--output "type=registry" . \ | ||
--build-arg commitHash=$SHORT_SHA |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,24 @@ | ||
[package] | ||
name = "electrs" | ||
name = "mempool-electrs" | ||
version = "3.0.0-dev" | ||
authors = ["Roman Zeyde <[email protected]>"] | ||
authors = [ | ||
"Roman Zeyde <[email protected]>", | ||
"Nadav Ivgi <[email protected]>", | ||
"wiz <[email protected]>", | ||
"junderw <[email protected]>" | ||
] | ||
description = "An efficient re-implementation of Electrum Server in Rust" | ||
license = "MIT" | ||
homepage = "https://github.com/mempool/electrs" | ||
repository = "https://github.com/mempool/electrs" | ||
publish = false | ||
keywords = ["bitcoin", "electrum", "server", "index", "database"] | ||
documentation = "https://docs.rs/electrs/" | ||
readme = "README.md" | ||
edition = "2018" | ||
|
||
[lib] | ||
name = "electrs" | ||
|
||
[features] | ||
default = [] | ||
liquid = [ "elements" ] | ||
|
Oops, something went wrong.