-
Notifications
You must be signed in to change notification settings - Fork 47
test: improve dev environment for integration tests #98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
qlrd
wants to merge
4
commits into
diybitcoinhardware:master
Choose a base branch
from
qlrd:feat/improve-dev-environment
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,51 @@ | ||
| name: Code quality | ||
|
|
||
| on: | ||
| push: | ||
| pull_request: | ||
| workflow_dispatch: | ||
|
|
||
| concurrency: | ||
| group: code-quality-${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| isort: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: astral-sh/setup-uv@v4 | ||
| with: | ||
| enable-cache: true | ||
| - run: uv sync --dev | ||
| - name: isort (black profile) | ||
| run: uv run poe isort --check | ||
|
|
||
| format: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: astral-sh/setup-uv@v4 | ||
| with: | ||
| enable-cache: true | ||
| - run: uv sync --dev | ||
| - name: Ruff format | ||
| run: uv run poe format --check | ||
|
|
||
| pylint: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: astral-sh/setup-uv@v4 | ||
| with: | ||
| enable-cache: true | ||
| - run: uv sync --dev | ||
| - name: Pylint | ||
| run: uv run poe pylint | ||
|
|
||
| typos: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Typos (spell check) | ||
| uses: crate-ci/typos@v1.45.0 |
This file contains hidden or 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,57 @@ | ||
| name: Conventional commits | ||
|
|
||
| on: | ||
| push: | ||
| pull_request: | ||
|
|
||
| concurrency: | ||
| group: conventional-commits-${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| commit-messages: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} | ||
|
|
||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.12" | ||
|
|
||
| - name: Install checker | ||
| run: pip install "conventional-pre-commit==4.4.0" | ||
|
|
||
| - name: Verify pushed commits | ||
| if: github.event_name == 'push' | ||
| run: | | ||
| set -euo pipefail | ||
| before="${{ github.event.before }}" | ||
| after="${{ github.event.after }}" | ||
| check() { | ||
| git log -1 --format=%B "$1" > /tmp/commit-msg.txt | ||
| conventional-pre-commit /tmp/commit-msg.txt | ||
| } | ||
| if [ "$before" = "0000000000000000000000000000000000000000" ]; then | ||
| check "$after" | ||
| exit 0 | ||
| fi | ||
| for rev in $(git rev-list --no-merges "${before}..${after}"); do | ||
| check "$rev" | ||
| done | ||
|
|
||
| - name: Fetch PR base (for range) | ||
| if: github.event_name == 'pull_request' | ||
| run: git fetch --no-tags origin ${{ github.event.pull_request.base.sha }} | ||
|
|
||
| - name: Verify PR commits | ||
| if: github.event_name == 'pull_request' | ||
| run: | | ||
| set -euo pipefail | ||
| base="${{ github.event.pull_request.base.sha }}" | ||
| for rev in $(git rev-list --no-merges "${base}..HEAD"); do | ||
| git log -1 --format=%B "$rev" > /tmp/commit-msg.txt | ||
| conventional-pre-commit /tmp/commit-msg.txt | ||
| done |
This file contains hidden or 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,128 @@ | ||
| name: Tests | ||
|
|
||
| on: | ||
| push: | ||
| pull_request: | ||
| workflow_dispatch: | ||
|
|
||
| concurrency: | ||
| group: tests-${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| unit: | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| os: [ubuntu-latest, macos-latest] | ||
| runs-on: ${{ matrix.os }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: astral-sh/setup-uv@v4 | ||
| with: | ||
| enable-cache: true | ||
| - run: uv sync --dev | ||
| - name: Unit tests | ||
| run: uv run poe tests --coverage | ||
|
|
||
| integration: | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| os: [ubuntu-latest, macos-latest] | ||
| runs-on: ${{ matrix.os }} | ||
| timeout-minutes: 120 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: astral-sh/setup-uv@v4 | ||
| with: | ||
| enable-cache: true | ||
| - run: uv sync --dev | ||
|
|
||
| - name: Export daemon versions | ||
| run: grep -v '^#' tests/integration/daemon-versions.env | grep -v '^$' >> "$GITHUB_ENV" | ||
|
|
||
| - name: Restore daemon cache | ||
| id: daemon-cache | ||
| uses: actions/cache/restore@v4 | ||
| with: | ||
| path: .cache/embit-test-src-bin-cache | ||
| key: embit-daemons-v1-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('tests/integration/daemon-versions.env') }} | ||
| restore-keys: | | ||
| embit-daemons-v1-${{ runner.os }}-${{ runner.arch }}- | ||
|
|
||
| - name: Check if daemon binaries are present | ||
| id: need_toolchain | ||
| run: | | ||
| set -euo pipefail | ||
| HOST_ID="$(uname -s)-$(uname -m)" | ||
| B="${BITCOIN_REVISION:?}"; B="${B#v}" | ||
| E="${ELEMENTS_REVISION:?}" | ||
| ROOT="${GITHUB_WORKSPACE}/.cache/embit-test-src-bin-cache" | ||
| BC="${ROOT}/${HOST_ID}/bitcoin-v${B}/bitcoind" | ||
| EL="${ROOT}/${HOST_ID}/elements-${E}/elementsd" | ||
| if [[ -f "$BC" && -f "$EL" ]]; then | ||
| echo "Both daemons found in cache." | ||
| echo "install=false" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "install=true" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
|
||
| - name: Install runtime libs (Linux) | ||
| if: runner.os == 'Linux' | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y \ | ||
| libevent-dev \ | ||
| libboost-system-dev \ | ||
| libboost-filesystem-dev \ | ||
| libboost-thread-dev \ | ||
| libdb-dev \ | ||
| libsqlite3-dev | ||
|
|
||
| - name: Install build toolchain (Linux) | ||
| if: steps.need_toolchain.outputs.install == 'true' && runner.os == 'Linux' | ||
| run: | | ||
| sudo apt-get install -y \ | ||
| build-essential \ | ||
| pkg-config \ | ||
| libtool \ | ||
| autotools-dev \ | ||
| automake \ | ||
| cmake \ | ||
| git \ | ||
| curl \ | ||
| libssl-dev \ | ||
| libboost-test-dev \ | ||
| libboost-program-options-dev \ | ||
| zlib1g-dev | ||
|
|
||
| - name: Install runtime libs (macOS) | ||
| if: runner.os == 'macOS' | ||
| run: | | ||
| brew install \ | ||
| boost \ | ||
| libevent \ | ||
| openssl@3 \ | ||
| berkeley-db@4 \ | ||
| sqlite | ||
|
|
||
| - name: Install build toolchain (macOS) | ||
| if: steps.need_toolchain.outputs.install == 'true' && runner.os == 'macOS' | ||
| run: | | ||
| brew install \ | ||
| autoconf \ | ||
| automake \ | ||
| libtool \ | ||
| pkg-config \ | ||
| cmake | ||
|
|
||
| - name: Integration tests | ||
| run: uv run poe integration-tests | ||
|
|
||
| - name: Save daemon cache | ||
| if: always() && steps.daemon-cache.outputs.cache-hit != 'true' | ||
| uses: actions/cache/save@v4 | ||
| with: | ||
| path: .cache/embit-test-src-bin-cache | ||
| key: embit-daemons-v1-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('tests/integration/daemon-versions.env') }} | ||
This file contains hidden or 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
This file contains hidden or 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,6 +1,81 @@ | ||
| # Two hooks (approach 1): unit-only is fast; integration still builds/restores | ||
| # daemons. | ||
| # | ||
| # Skip when needed: | ||
| # | ||
| # SKIP=conventional-pre-commit,isort,ruff-format,pylint,shellcheck,typos,unit-test,integration-test git commit ... | ||
| # | ||
| # Typos uses --force-exclude so _typos.toml extend-exclude (tests, wordlists, | ||
| # i18n fixtures) applies when hooks pass explicit paths. | ||
| # | ||
| # Mirrors .github/workflows/code-quality.yml | ||
| # (isort → ruff → pylint → shellcheck → typos) and tests.yml. | ||
|
Comment on lines
+6
to
+12
|
||
| # | ||
| # After changing this file: pre-commit install --install-hooks (installs | ||
| # pre-commit + commit-msg hooks). | ||
| default_install_hook_types: | ||
| - pre-commit | ||
| - commit-msg | ||
|
|
||
| repos: | ||
| - repo: https://github.com/psf/black | ||
| rev: 22.3.0 | ||
| - repo: https://github.com/PyCQA/isort | ||
| rev: 6.0.1 | ||
| hooks: | ||
| - id: black | ||
| language_version: python3 | ||
| - id: isort | ||
| name: isort (black profile) | ||
| args: [--settings-path=pyproject.toml] | ||
| files: ^src/embit/ | ||
|
|
||
| - repo: https://github.com/astral-sh/ruff-pre-commit | ||
| rev: v0.15.12 | ||
| hooks: | ||
| - id: ruff-format | ||
| files: ^(src/embit|tests)/ | ||
|
|
||
| - repo: https://github.com/pylint-dev/pylint | ||
| rev: v3.3.8 | ||
| hooks: | ||
| - id: pylint | ||
| name: pylint | ||
| args: [--errors-only, --rcfile=pyproject.toml] | ||
| additional_dependencies: [] | ||
| files: ^src/embit/ | ||
|
|
||
| - repo: https://github.com/crate-ci/typos | ||
| rev: v1.45.0 | ||
| hooks: | ||
| - id: typos | ||
| name: typos (spell check) | ||
| args: [--force-exclude] | ||
|
|
||
| - repo: local | ||
| hooks: | ||
| - id: test-clean | ||
| name: test-clean | ||
| entry: python -c 'import shutil, os; os.path.exists("htmlcov") and shutil.rmtree("htmlcov")' | ||
| language: system | ||
| pass_filenames: false | ||
| always_run: true | ||
| require_serial: true | ||
| - id: unit-test | ||
| name: unit-test | ||
| entry: uv run poe tests | ||
| language: system | ||
| pass_filenames: false | ||
| always_run: true | ||
| require_serial: true | ||
| - id: integration-test | ||
| name: integration-test | ||
| entry: bash -c 'ulimit -n 10240 2>/dev/null; uv run poe integration-tests' | ||
| language: system | ||
| pass_filenames: false | ||
| always_run: true | ||
| require_serial: true | ||
|
|
||
| - repo: https://github.com/compilerla/conventional-pre-commit | ||
| rev: v4.4.0 | ||
| hooks: | ||
| - id: conventional-pre-commit | ||
| name: conventional-commit-1.0 | ||
| stages: [commit-msg] | ||
| args: [] | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.