From 2ff923a243e65e01c8b8ae7ad754329f952f891a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20L=C3=B3pez?= Date: Fri, 3 Jan 2025 13:14:46 +0100 Subject: [PATCH 1/5] ci: unify CI workflows --- .github/workflows/ci.yml | 97 ++++++++++++++++++++++++++++++++ .github/workflows/linux-ci.yml | 39 ------------- .github/workflows/mac-ci.yml | 39 ------------- .github/workflows/windows-ci.yml | 40 ------------- 4 files changed, 97 insertions(+), 118 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .github/workflows/linux-ci.yml delete mode 100644 .github/workflows/mac-ci.yml delete mode 100644 .github/workflows/windows-ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..15e9f95 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,97 @@ +name: CI + +on: + push: + branches: + - master + - dev + pull_request: + schedule: + # run CI every day even if no PRs/merges occur + - cron: '0 12 * * *' + +jobs: + linux: + name: CI (Linux) + runs-on: ubuntu-latest + strategy: + matrix: + python: + - "3.8" + - "3.9" + - "3.10" + - "3.11" + - "3.12" + - "3.13" + type: ["solc_upgrade", "linux", "solc"] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python }} + - name: Install solc-select + run: | + sudo pip install . + solc-select install all + - name: Run Tests + env: + TEST_TYPE: ${{ matrix.type }} + run: | + bash scripts/test_${TEST_TYPE}.sh + + macos: + name: CI (macOS) + runs-on: macos-latest + strategy: + matrix: + python: + - "3.8" + - "3.9" + - "3.10" + - "3.11" + - "3.12" + - "3.13" + type: ["solc_upgrade", "macos", "solc"] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python }} + - name: Install solc-select + run: | + sudo pip install . + solc-select install all + - name: Run Tests + env: + TEST_TYPE: ${{ matrix.type }} + run: | + bash scripts/test_${TEST_TYPE}.sh + + windows: + name: CI (Windows) + runs-on: windows-2022 + strategy: + matrix: + python: + - "3.8" + - "3.9" + - "3.10" + - "3.11" + - "3.12" + - "3.13" + type: ["windows", "solc"] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python }} + - name: Install solc-select + run: | + pip install . --user + solc-select install all + - name: Run Tests + env: + TEST_TYPE: ${{ matrix.type }} + run: | + bash scripts/test_${TEST_TYPE}.sh + shell: bash diff --git a/.github/workflows/linux-ci.yml b/.github/workflows/linux-ci.yml deleted file mode 100644 index ffe2c14..0000000 --- a/.github/workflows/linux-ci.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: CI - -on: - push: - branches: - - master - - dev - pull_request: - schedule: - # run CI every day even if no PRs/merges occur - - cron: '0 12 * * *' - -jobs: - tests: - runs-on: ubuntu-latest - strategy: - matrix: - python: - - "3.8" - - "3.9" - - "3.10" - - "3.11" - - "3.12" - - "3.13" - type: ["solc_upgrade", "linux", "solc"] - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python }} - - name: Install solc-select - run: | - sudo pip install . - solc-select install all - - name: Run Tests - env: - TEST_TYPE: ${{ matrix.type }} - run: | - bash scripts/test_${TEST_TYPE}.sh \ No newline at end of file diff --git a/.github/workflows/mac-ci.yml b/.github/workflows/mac-ci.yml deleted file mode 100644 index d566963..0000000 --- a/.github/workflows/mac-ci.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: CI - -on: - push: - branches: - - master - - dev - pull_request: - schedule: - # run CI every day even if no PRs/merges occur - - cron: '0 12 * * *' - -jobs: - tests: - runs-on: macos-latest - strategy: - matrix: - python: - - "3.8" - - "3.9" - - "3.10" - - "3.11" - - "3.12" - - "3.13" - type: ["solc_upgrade", "macos", "solc"] - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python }} - - name: Install solc-select - run: | - sudo pip install . - solc-select install all - - name: Run Tests - env: - TEST_TYPE: ${{ matrix.type }} - run: | - bash scripts/test_${TEST_TYPE}.sh diff --git a/.github/workflows/windows-ci.yml b/.github/workflows/windows-ci.yml deleted file mode 100644 index c4f1c7f..0000000 --- a/.github/workflows/windows-ci.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: CI - -on: - push: - branches: - - master - - dev - pull_request: - schedule: - # run CI every day even if no PRs/merges occur - - cron: '0 12 * * *' - -jobs: - tests: - runs-on: windows-2022 - strategy: - matrix: - python: - - "3.8" - - "3.9" - - "3.10" - - "3.11" - - "3.12" - - "3.13" - type: ["windows", "solc"] - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python }} - - name: Install solc-select - run: | - pip install . --user - solc-select install all - - name: Run Tests - env: - TEST_TYPE: ${{ matrix.type }} - run: | - bash scripts/test_${TEST_TYPE}.sh - shell: bash From 69be6e73ae19034a49a49947b553d010b2959425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20L=C3=B3pez?= Date: Fri, 3 Jan 2025 13:28:46 +0100 Subject: [PATCH 2/5] ci: deduplicate jobs --- .github/workflows/ci.yml | 82 ++++++---------------------------------- scripts/test_solc.sh | 4 +- 2 files changed, 14 insertions(+), 72 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 15e9f95..f7c84ea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,19 +11,17 @@ on: - cron: '0 12 * * *' jobs: - linux: - name: CI (Linux) - runs-on: ubuntu-latest + tests: + name: CI (Python ${{ matrix.python }} on ${{ matrix.os }}, ${{ matrix.type }} test) + runs-on: ${{ matrix.os }} + defaults: + run: + shell: bash strategy: matrix: - python: - - "3.8" - - "3.9" - - "3.10" - - "3.11" - - "3.12" - - "3.13" - type: ["solc_upgrade", "linux", "solc"] + python: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] + os: ["ubuntu-latest", "macos-latest", "windows-2022"] + type: ["solc", "solc_upgrade", "os_specific"] steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -31,67 +29,11 @@ jobs: python-version: ${{ matrix.python }} - name: Install solc-select run: | - sudo pip install . + ${{ (matrix.os != 'windows-2022' && 'sudo pip install .') || 'pip install . --user' }} solc-select install all - name: Run Tests env: - TEST_TYPE: ${{ matrix.type }} + TEST_TYPE: ${{ (matrix.type != 'os_specific' && matrix.type) || runner.os }} run: | + TEST_TYPE="$(echo "$TEST_TYPE" | tr '[:upper:]' '[:lower:]')" bash scripts/test_${TEST_TYPE}.sh - - macos: - name: CI (macOS) - runs-on: macos-latest - strategy: - matrix: - python: - - "3.8" - - "3.9" - - "3.10" - - "3.11" - - "3.12" - - "3.13" - type: ["solc_upgrade", "macos", "solc"] - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python }} - - name: Install solc-select - run: | - sudo pip install . - solc-select install all - - name: Run Tests - env: - TEST_TYPE: ${{ matrix.type }} - run: | - bash scripts/test_${TEST_TYPE}.sh - - windows: - name: CI (Windows) - runs-on: windows-2022 - strategy: - matrix: - python: - - "3.8" - - "3.9" - - "3.10" - - "3.11" - - "3.12" - - "3.13" - type: ["windows", "solc"] - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python }} - - name: Install solc-select - run: | - pip install . --user - solc-select install all - - name: Run Tests - env: - TEST_TYPE: ${{ matrix.type }} - run: | - bash scripts/test_${TEST_TYPE}.sh - shell: bash diff --git a/scripts/test_solc.sh b/scripts/test_solc.sh index db20a04..6e328cd 100644 --- a/scripts/test_solc.sh +++ b/scripts/test_solc.sh @@ -91,7 +91,7 @@ fi echo "SUCCESS: solc080_fail_compile" UNINSTALL_PATH=$HOME/.solc-select/artifacts/solc-0.8.9 -rm -rf $UNINSTALL_PATH # uninstall solc 0.8.9 +rm -rf $UNINSTALL_PATH{,.exe} # uninstall solc 0.8.9 execute=$(solc-select use 0.8.9 --always-install) if [[ "$execute" != *"Switched global version to 0.8.9"* ]]; then echo "FAILED: use - always install" @@ -100,7 +100,7 @@ fi echo "SUCCESS: use - always install" UNINSTALL_PATH=$HOME/.solc-select/artifacts/solc-0.8.1 -rm -rf $UNINSTALL_PATH # uninstall solc 0.8.1 +rm -rf $UNINSTALL_PATH{,.exe} # uninstall solc 0.8.1 execute=$(solc-select use 0.8.1 2>&1 || true) if [[ $execute != *"'0.8.1' must be installed prior to use"* ]]; then echo "FAILED: use - no install" From 27072aad38f337a1616f07f2111d18635cb88742 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20L=C3=B3pez?= Date: Fri, 3 Jan 2025 13:33:38 +0100 Subject: [PATCH 3/5] ci: add concurrency control Closes #165 --- .github/workflows/ci.yml | 4 ++++ .github/workflows/lint.yml | 4 ++++ .github/workflows/pip-audit.yml | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f7c84ea..c8189d6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,6 +10,10 @@ on: # run CI every day even if no PRs/merges occur - cron: '0 12 * * *' +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: tests: name: CI (Python ${{ matrix.python }} on ${{ matrix.os }}, ${{ matrix.type }} test) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 80fb5bc..5610cf7 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -13,6 +13,10 @@ on: # run CI every day even if no PRs/merges occur - cron: '0 12 * * *' +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + permissions: contents: read packages: read diff --git a/.github/workflows/pip-audit.yml b/.github/workflows/pip-audit.yml index fb3a219..cfdc1da 100644 --- a/.github/workflows/pip-audit.yml +++ b/.github/workflows/pip-audit.yml @@ -8,6 +8,10 @@ on: schedule: - cron: "0 12 * * *" +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: pip-audit: runs-on: ubuntu-latest From 907550fbdb5edd4d6a8002c5a6f425f3b2c0fb6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20L=C3=B3pez?= Date: Fri, 3 Jan 2025 14:12:03 +0100 Subject: [PATCH 4/5] ci: use a venv instead of system-wide installs --- .github/workflows/ci.yml | 7 +++++-- scripts/test_linux.sh | 1 - scripts/test_macos.sh | 2 ++ scripts/test_solc.sh | 2 ++ scripts/test_solc_upgrade.sh | 7 ++++--- scripts/test_windows.sh | 2 ++ 6 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c8189d6..3b57547 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,15 +29,18 @@ jobs: steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 + id: python with: python-version: ${{ matrix.python }} - name: Install solc-select run: | - ${{ (matrix.os != 'windows-2022' && 'sudo pip install .') || 'pip install . --user' }} - solc-select install all + ${{ steps.python.outputs.python-path }} -m venv test-venv + source test-venv/bin/activate + pip3 install . - name: Run Tests env: TEST_TYPE: ${{ (matrix.type != 'os_specific' && matrix.type) || runner.os }} run: | + source test-venv/bin/activate TEST_TYPE="$(echo "$TEST_TYPE" | tr '[:upper:]' '[:lower:]')" bash scripts/test_${TEST_TYPE}.sh diff --git a/scripts/test_linux.sh b/scripts/test_linux.sh index 6564bf1..d47e1bb 100644 --- a/scripts/test_linux.sh +++ b/scripts/test_linux.sh @@ -1,7 +1,6 @@ #!/usr/bin/env bash set -euo pipefail -sudo pip3 install . solc-select install all use_version=$(solc-select use 0.4.0) diff --git a/scripts/test_macos.sh b/scripts/test_macos.sh index 232605e..7edde9f 100644 --- a/scripts/test_macos.sh +++ b/scripts/test_macos.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash set -euo pipefail +solc-select install all + use_version=$(solc-select use 0.3.6) if [[ $use_version != "Switched global version to 0.3.6"* ]]; then echo "OS X FAILED: set minimum version" diff --git a/scripts/test_solc.sh b/scripts/test_solc.sh index 6e328cd..6bacea9 100644 --- a/scripts/test_solc.sh +++ b/scripts/test_solc.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash set -euo pipefail +solc-select install 0.4.5 0.5.0 0.6.0 0.7.0 0.8.0 0.8.1 0.8.9 + ## solc 0.4.5 ## solc-select use 0.4.5 &> /dev/null solc ./scripts/solidity_tests/solc045_success.sol diff --git a/scripts/test_solc_upgrade.sh b/scripts/test_solc_upgrade.sh index de504d0..387a03b 100644 --- a/scripts/test_solc_upgrade.sh +++ b/scripts/test_solc_upgrade.sh @@ -2,15 +2,16 @@ set -euo pipefail ### Install old version of solc -sudo pip3 uninstall --yes solc-select -sudo pip3 install solc-select +pip3 uninstall --yes solc-select +pip3 install solc-select solc-select use 0.8.0 --always-install old_solc_version=$(solc --version) solc-select install 0.4.11 0.5.0 0.6.12 0.7.3 0.8.3 all_old_versions=$(solc-select versions | sort) ### Install new version of solc -sudo pip3 install -e . +pip3 uninstall --yes solc-select +pip3 install -e . new_solc_version=$(solc --version) all_new_versions=$(solc-select versions | sort) diff --git a/scripts/test_windows.sh b/scripts/test_windows.sh index acc284b..51097c6 100644 --- a/scripts/test_windows.sh +++ b/scripts/test_windows.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash set -euo pipefail +solc-select install all + use_version=$(solc-select use 0.4.5) if [[ $use_version != "Switched global version to 0.4.5"* ]]; then echo "WINDOWS FAILED: minimum version" From 50d0d246f16cba45840700db264f93b2ff5b895d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20L=C3=B3pez?= Date: Fri, 3 Jan 2025 14:28:10 +0100 Subject: [PATCH 5/5] ci: fix execution on Windows --- .github/workflows/ci.yml | 14 ++++++++------ scripts/test_solc.sh | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3b57547..3b8c31a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,9 +18,6 @@ jobs: tests: name: CI (Python ${{ matrix.python }} on ${{ matrix.os }}, ${{ matrix.type }} test) runs-on: ${{ matrix.os }} - defaults: - run: - shell: bash strategy: matrix: python: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] @@ -32,15 +29,20 @@ jobs: id: python with: python-version: ${{ matrix.python }} - - name: Install solc-select + - name: Create Python virtual environment run: | ${{ steps.python.outputs.python-path }} -m venv test-venv - source test-venv/bin/activate + - name: Install solc-select + shell: bash + run: | + source test-venv/${{ (runner.os == 'Windows' && 'Scripts') || 'bin' }}/activate + python -m pip install --upgrade pip pip3 install . - name: Run Tests + shell: bash env: TEST_TYPE: ${{ (matrix.type != 'os_specific' && matrix.type) || runner.os }} run: | - source test-venv/bin/activate + source test-venv/${{ (runner.os == 'Windows' && 'Scripts') || 'bin' }}/activate TEST_TYPE="$(echo "$TEST_TYPE" | tr '[:upper:]' '[:lower:]')" bash scripts/test_${TEST_TYPE}.sh diff --git a/scripts/test_solc.sh b/scripts/test_solc.sh index 6bacea9..55b3978 100644 --- a/scripts/test_solc.sh +++ b/scripts/test_solc.sh @@ -92,7 +92,7 @@ if [[ "$execute" != *"Error: Explicit type conversion not allowed"* ]]; then fi echo "SUCCESS: solc080_fail_compile" -UNINSTALL_PATH=$HOME/.solc-select/artifacts/solc-0.8.9 +UNINSTALL_PATH=${VIRTUAL_ENV:-$HOME}/.solc-select/artifacts/solc-0.8.9 rm -rf $UNINSTALL_PATH{,.exe} # uninstall solc 0.8.9 execute=$(solc-select use 0.8.9 --always-install) if [[ "$execute" != *"Switched global version to 0.8.9"* ]]; then @@ -101,7 +101,7 @@ if [[ "$execute" != *"Switched global version to 0.8.9"* ]]; then fi echo "SUCCESS: use - always install" -UNINSTALL_PATH=$HOME/.solc-select/artifacts/solc-0.8.1 +UNINSTALL_PATH=${VIRTUAL_ENV:-$HOME}/.solc-select/artifacts/solc-0.8.1 rm -rf $UNINSTALL_PATH{,.exe} # uninstall solc 0.8.1 execute=$(solc-select use 0.8.1 2>&1 || true) if [[ $execute != *"'0.8.1' must be installed prior to use"* ]]; then