From 123afad33a170da55f68a861f3212ebb412f02b4 Mon Sep 17 00:00:00 2001 From: Walter Boring Date: Thu, 3 Sep 2026 11:12:11 -0400 Subject: [PATCH 1/4] Add GitHub Actions CI for lint and tests --- .github/workflows/ci.yml | 50 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..f1fe2fd --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,50 @@ +name: CI + +on: + pull_request: + branches: + - master + push: + branches: + - master + +permissions: + contents: read + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12.13' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -r requirements.txt -r test-requirements.txt + - name: Run flake8 + run: flake8 . + + unit-tests: + name: Unit tests + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12.13' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -r requirements.txt -r test-requirements.txt + - name: Run unit tests + run: stestr run + - name: Show slowest tests + if: always() + run: stestr slowest From 0703f0aa211468fbbdf24436eae1cf30c8cf6abd Mon Sep 17 00:00:00 2001 From: Walter Boring Date: Thu, 3 Sep 2026 11:17:10 -0400 Subject: [PATCH 2/4] Fix CI tool compatibility and empty test discovery --- .github/workflows/ci.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f1fe2fd..c2b2320 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,6 +26,7 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install -r requirements.txt -r test-requirements.txt + python -m pip install 'importlib-metadata<5' - name: Run flake8 run: flake8 . @@ -44,7 +45,9 @@ jobs: python -m pip install --upgrade pip python -m pip install -r requirements.txt -r test-requirements.txt - name: Run unit tests - run: stestr run - - name: Show slowest tests - if: always() - run: stestr slowest + run: | + if [ -d openstack_exporter/tests ]; then + stestr run + else + echo "No OpenStack exporter tests are present on this revision." + fi From 38649259423f5b196243241dc3c0bab303701ded Mon Sep 17 00:00:00 2001 From: Walter Boring Date: Thu, 3 Sep 2026 11:19:22 -0400 Subject: [PATCH 3/4] Pin compatible importlib metadata version --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c2b2320..cf57167 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install -r requirements.txt -r test-requirements.txt - python -m pip install 'importlib-metadata<5' + python -m pip install --force-reinstall 'importlib-metadata==4.13.0' - name: Run flake8 run: flake8 . From 05f4b29f936affca06c1c3e467fb0a29cf1ebeb7 Mon Sep 17 00:00:00 2001 From: Walter Boring Date: Thu, 3 Sep 2026 11:24:03 -0400 Subject: [PATCH 4/4] Use Python 3.12 compatible lint tooling --- .github/workflows/ci.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cf57167..5a1dc83 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,12 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install -r requirements.txt -r test-requirements.txt - python -m pip install --force-reinstall 'importlib-metadata==4.13.0' + # hacking 3.1 pins flake8 3.8, which cannot run on Python 3.12. + python -m pip install --no-deps \ + 'flake8==5.0.4' \ + 'pycodestyle==2.9.1' \ + 'pyflakes==2.5.0' \ + 'mccabe==0.7.0' - name: Run flake8 run: flake8 .