Skip to content

Commit

Permalink
Refactor the main Makefile (#3988)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtraglia authored Dec 13, 2024
1 parent 18af2af commit 98cf01d
Show file tree
Hide file tree
Showing 14 changed files with 331 additions and 439 deletions.
70 changes: 25 additions & 45 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ commands:
description: "Restore the cache with pyspec keys"
steps:
- restore_cached_venv:
venv_name: v25-pyspec
venv_name: v30-pyspec
reqs_checksum: cache-{{ checksum "setup.py" }}-{{ checksum "requirements_preinstallation.txt" }}
save_pyspec_cached_venv:
description: Save a venv into a cache with pyspec keys"
steps:
- save_cached_venv:
venv_name: v25-pyspec
venv_name: v30-pyspec
reqs_checksum: cache-{{ checksum "setup.py" }}-{{ checksum "requirements_preinstallation.txt" }}
venv_path: ./venv
jobs:
checkout_specs:
docker:
- image: cimg/python:3.12.4
- image: cimg/python:3.12-node
working_directory: ~/specs-repo
steps:
# Restore git repo at point close to target branch/revision, to speed up checkout
Expand All @@ -67,152 +67,134 @@ jobs:
- ~/specs-repo
install_pyspec_test:
docker:
- image: cimg/python:3.12.4
- image: cimg/python:3.12-node
working_directory: ~/specs-repo
steps:
- restore_cache:
key: v3-specs-repo-{{ .Branch }}-{{ .Revision }}
- restore_pyspec_cached_venv
- run:
name: Install pyspec requirements
command: make install_test
command: make eth2spec
- save_pyspec_cached_venv
test-phase0:
docker:
- image: cimg/python:3.12.4
- image: cimg/python:3.12-node
working_directory: ~/specs-repo
steps:
- restore_cache:
key: v3-specs-repo-{{ .Branch }}-{{ .Revision }}
- restore_pyspec_cached_venv
- run:
name: Run py-tests
command: make citest fork=phase0
command: make test fork=phase0
- store_test_results:
path: tests/core/pyspec/test-reports
test-altair:
docker:
- image: cimg/python:3.12.4
- image: cimg/python:3.12-node
working_directory: ~/specs-repo
steps:
- restore_cache:
key: v3-specs-repo-{{ .Branch }}-{{ .Revision }}
- restore_pyspec_cached_venv
- run:
name: Run py-tests
command: make citest fork=altair
command: make test fork=altair
- store_test_results:
path: tests/core/pyspec/test-reports
test-bellatrix:
docker:
- image: cimg/python:3.12.4
- image: cimg/python:3.12-node
working_directory: ~/specs-repo
steps:
- restore_cache:
key: v3-specs-repo-{{ .Branch }}-{{ .Revision }}
- restore_pyspec_cached_venv
- run:
name: Run py-tests
command: make citest fork=bellatrix
command: make test fork=bellatrix
- store_test_results:
path: tests/core/pyspec/test-reports
test-capella:
docker:
- image: cimg/python:3.12.4
- image: cimg/python:3.12-node
working_directory: ~/specs-repo
steps:
- restore_cache:
key: v3-specs-repo-{{ .Branch }}-{{ .Revision }}
- restore_pyspec_cached_venv
- run:
name: Run py-tests
command: make citest fork=capella
command: make test fork=capella
- store_test_results:
path: tests/core/pyspec/test-reports
test-deneb:
docker:
- image: cimg/python:3.12.4
- image: cimg/python:3.12-node
working_directory: ~/specs-repo
steps:
- restore_cache:
key: v3-specs-repo-{{ .Branch }}-{{ .Revision }}
- restore_pyspec_cached_venv
- run:
name: Run py-tests
command: make citest fork=deneb
command: make test fork=deneb
- store_test_results:
path: tests/core/pyspec/test-reports
test-electra:
docker:
- image: cimg/python:3.12.4
- image: cimg/python:3.12-node
working_directory: ~/specs-repo
steps:
- restore_cache:
key: v3-specs-repo-{{ .Branch }}-{{ .Revision }}
- restore_pyspec_cached_venv
- run:
name: Run py-tests
command: make citest fork=electra
command: make test fork=electra
- store_test_results:
path: tests/core/pyspec/test-reports
test-fulu:
docker:
- image: cimg/python:3.12.4
- image: cimg/python:3.12-node
working_directory: ~/specs-repo
steps:
- restore_cache:
key: v3-specs-repo-{{ .Branch }}-{{ .Revision }}
- restore_pyspec_cached_venv
- run:
name: Run py-tests
command: make citest fork=fulu
command: make test fork=fulu
- store_test_results:
path: tests/core/pyspec/test-reports
test-whisk:
docker:
- image: cimg/python:3.12.4
- image: cimg/python:3.12-node
working_directory: ~/specs-repo
steps:
- restore_cache:
key: v3-specs-repo-{{ .Branch }}-{{ .Revision }}
- restore_pyspec_cached_venv
- run:
name: Run py-tests
command: make citest fork=whisk
command: make test fork=whisk
- store_test_results:
path: tests/core/pyspec/test-reports
table_of_contents:
docker:
- image: circleci/node:10.16.3
working_directory: ~/specs-repo
steps:
- checkout
- run:
name: Check table of contents
command: sudo npm install -g doctoc@2.2.0 && make check_toc
codespell:
docker:
- image: cimg/python:3.12.4
working_directory: ~/specs-repo
steps:
- checkout
- run:
name: Check codespell
command: pip install 'codespell<3.0.0,>=2.0.0' --user && make codespell
lint:
docker:
- image: cimg/python:3.12.4
- image: cimg/python:3.12-node
working_directory: ~/specs-repo
steps:
- restore_cache:
key: v3-specs-repo-{{ .Branch }}-{{ .Revision }}
- restore_pyspec_cached_venv
- run:
name: Install doctoc
command: sudo npm install -g doctoc@2.2.0
- run:
name: Run linter for pyspec
command: make lint
- run:
name: Run linter for test generators
command: make lint_generators
workflows:
version: 2.1
test_spec:
Expand Down Expand Up @@ -245,8 +227,6 @@ workflows:
- test-whisk:
requires:
- install_pyspec_test
- table_of_contents
- codespell
- lint:
requires:
- install_pyspec_test
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Build docs
run: make copy_docs
run: make _copy_docs
- uses: actions/setup-python@v4
with:
python-version: 3.x
Expand Down
11 changes: 1 addition & 10 deletions .github/workflows/generate_vectors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,10 @@ jobs:
with:
python-version: '3.12.4'
cache: ''
- name: Clean up Spec Repository
run: |
cd consensus-specs
make clean
- name: Install dependencies and generate pyspec
run: |
cd consensus-specs
make install_test
make -B pyspec
- name: Generate tests
run: |
cd consensus-specs
make -j 16 generate_tests 2>&1 | tee ../consensustestgen.log
make -j 16 gen_all 2>&1 | tee ../consensustestgen.log
cp -r presets/ ../consensus-spec-tests/presets
cp -r configs/ ../consensus-spec-tests/configs
find . -type d -empty -delete
Expand Down
55 changes: 13 additions & 42 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,50 +24,25 @@ on:
- cron: '0 0 * * *'

jobs:
table_of_contents:
runs-on: [self-hosted-ghr-custom, size-s-x64, profile-consensusSpecs]
steps:
lint:
runs-on: [self-hosted-ghr-custom, size-l-x64, profile-consensusSpecs]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: ''
- name: Check table of contents
run: npm install -g doctoc@2.2.0 && make check_toc

codespell:
runs-on: [self-hosted-ghr-custom, size-s-x64, profile-consensusSpecs]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12.4'
cache: ''
- name: Check codespell
run: make codespell

lint:
runs-on: [self-hosted-ghr-custom, size-l-x64, profile-consensusSpecs]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Rust for dependencies
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12.4'
cache: ''
- name: Install pyspec requirements
run: make install_test
- name: Install doctoc
run: npm install -g doctoc@2.2.0
- name: Run linter for pyspec
run: make lint
- name: Run linter for test generators
run: make lint_generators

whitespace:
runs-on: [self-hosted-ghr-custom, size-l-x64, profile-consensusSpecs]
Expand All @@ -83,7 +58,7 @@ jobs:
pyspec-tests:
runs-on: [self-hosted-ghr-custom, size-xl-x64, profile-consensusSpecs]
needs: [lint,codespell,table_of_contents]
needs: [lint]
strategy:
matrix:
version: ["phase0", "altair", "bellatrix", "capella", "deneb", "electra", "fulu", "whisk"]
Expand All @@ -97,26 +72,24 @@ jobs:
with:
python-version: '3.12.4'
cache: ''
- name: set TEST_PRESET_TYPE
- name: set preset
if: github.event.inputs.test_preset_type != ''
run: |
echo "spec_test_preset_type=${{ github.event.inputs.test_preset_type || env.TEST_PRESET_TYPE }}" >> $GITHUB_ENV
- name: set TEST_PRESET_TYPE
- name: set preset
if: ${{ (github.event_name == 'push' && github.ref_name != 'master') || github.event_name == 'pull_request' }}
run: |
echo "spec_test_preset_type=${{ env.TEST_PRESET_TYPE}}" >> $GITHUB_ENV
- name: set TEST_PRESET_TYPE
echo "spec_test_preset_type=${{ env.TEST_PRESET_TYPE }}" >> $GITHUB_ENV
- name: set preset
if: ${{ github.event_name == 'push' && github.ref_name == 'master' }}
run: |
echo "spec_test_preset_type=mainnet" >> $GITHUB_ENV
- name: set TEST_PRESET_TYPE
- name: set preset
if: github.event.schedule=='0 0 * * *'
run: |
echo "spec_test_preset_type=mainnet" >> $GITHUB_ENV
- name: Install pyspec requirements
run: make install_test
- name: test-${{ matrix.version }}
run: make citest fork=${{ matrix.version }} TEST_PRESET_TYPE=${{env.spec_test_preset_type}}
run: make test fork=${{ matrix.version }} preset=${{ env.spec_test_preset_type }}
- uses: actions/upload-artifact@v4
if: always()
with:
Expand All @@ -133,10 +106,8 @@ jobs:
with:
python-version: '3.12.4'
cache: ''
- name: Install pyspec requirements
run: make install_test
- name: Run generators with --modcheck
run: make generate_tests modcheck=true 2>&1 | tee consensustestgen.log
run: make gen_all modcheck=true 2>&1 | tee consensustestgen.log
- name: Check for errors
run: |
if grep -q "\[ERROR\]" consensustestgen.log; then
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ venv
.venv
/.pytest_cache
*.swp
.eth2spec

build/
output/
Expand Down
Loading

0 comments on commit 98cf01d

Please sign in to comment.