diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2df4ad07..c48590bd 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -3,76 +3,117 @@ name: CI on: [ pull_request ] jobs: - pre-commit: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - - uses: snok/install-poetry@v1 - with: - virtualenvs-create: true - virtualenvs-in-project: true - installer-parallel: true - - uses: actions/setup-python@v5 - with: - python-version: "3.10" - cache: 'poetry' - - name: Install dependencies - run: poetry install --no-interaction --no-root - - run: source .venv/bin/activate - - uses: pre-commit/action@v3.0.0 - - fast-tests: - runs-on: ubuntu-22.04 - needs: [ pre-commit ] - steps: - - uses: actions/checkout@v4 - - name: Unit tests - run: ./scripts/unit_tests.sh - - name: Execute Mypy - run: ./scripts/mypy.sh - - name: Build aspect integration tests - run: | - cd test/aspect - bazel build //... - - name: Build examples - run: | - cd examples - bazel build //... + # pre-commit: + # runs-on: ubuntu-22.04 + # steps: + # - uses: actions/checkout@v4 + # - uses: snok/install-poetry@v1 + # with: + # virtualenvs-create: true + # virtualenvs-in-project: true + # installer-parallel: true + # - uses: actions/setup-python@v5 + # with: + # python-version: "3.10" + # cache: 'poetry' + # - name: Install dependencies + # run: poetry install --no-interaction --no-root + # - run: source .venv/bin/activate + # - uses: pre-commit/action@v3.0.0 + # + # fast-tests: + # runs-on: ubuntu-22.04 + # needs: [ pre-commit ] + # steps: + # - uses: actions/checkout@v4 + # - name: Unit tests + # run: ./scripts/unit_tests.sh + # - name: Execute Mypy + # run: ./scripts/mypy.sh + # - name: Build aspect integration tests + # run: | + # cd test/aspect + # bazel build //... + # - name: Build examples + # run: | + # cd examples + # bazel build //... integration-tests-aspect: - runs-on: ubuntu-22.04 - needs: [ fast-tests ] + strategy: + matrix: + os: [ ubuntu-22.04, macos-12, windows-2022 ] + runs-on: ${{ matrix.os }} + #needs: [ fast-tests ] steps: - uses: actions/checkout@v4 - name: Integration tests - Aspect run: | - cd test/aspect - ./execute_tests.py + cd test + cd aspect + python execute_tests.py + # - name: Integration tests - Aspect + # if: runner.os == 'Linux' || runner.os == 'macOS' + # run: | + # cd test/aspect + # ./execute_tests.py + # - name: Integration tests - Aspect + # if: runner.os == 'Windows' + # run: | + # cd test\aspect + # python execute_tests.py integration-tests-apply-fixes: - runs-on: ubuntu-22.04 - needs: [ fast-tests ] + strategy: + matrix: + os: [ ubuntu-22.04, macos-12, windows-2022 ] + runs-on: ${{ matrix.os }} + #needs: [ fast-tests ] steps: - - run: | - mkdir --parents /tmp/bin + - uses: actions/checkout@v4 + - name: Prepare buildozer + if: runner.os == 'Linux' + run: | + mkdir -p /tmp/bin wget --no-verbose https://github.com/bazelbuild/buildtools/releases/download/v6.4.0/buildozer-linux-amd64 -O /tmp/bin/buildozer chmod +x /tmp/bin/buildozer - - uses: actions/checkout@v4 + - name: Prepare buildozer + if: runner.os == 'macOS' + run: | + mkdir -p /tmp/bin + wget --no-verbose https://github.com/bazelbuild/buildtools/releases/download/v6.4.0/buildozer-darwin-amd64 -O /tmp/bin/buildozer + chmod +x /tmp/bin/buildozer + - name: Prepare buildozer + if: runner.os == 'Windows' + run: | + New-Item -Path "D:\" -Name "Downloads" -ItemType Directory + Invoke-WebRequest -Uri "https://github.com/bazelbuild/buildtools/releases/download/v6.4.0/buildozer-windows-amd64.exe" -OutFile "D:\Downloads\buildozer.exe" - name: Integration tests - Applying fixes + if: runner.os == 'Linux' || runner.os == 'macOS' run: | export PATH=/tmp/bin:$PATH - ./test/apply_fixes/execute_tests.py - - integration-tests-examples: - runs-on: ubuntu-22.04 - needs: [ fast-tests ] - steps: - - uses: actions/checkout@v4 - - name: Integration tests - Examples - run: | - cd examples - ./test.py - - name: Integration tests - Examples with legacy WORKSPACE setup + ./test/apply_fixes/execute_tests.py -v + - name: Integration tests - Applying fixes + if: runner.os == 'Windows' run: | - cd examples - ./test.py --legacy-workspace + echo "PATH=$env:PATH;D:\Downloads" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + python test/apply_fixes/execute_tests.py -v + + +# Works, but commented to ave resources +# integration-tests-examples: +# strategy: +# matrix: +# os: [ ubuntu-22.04, macos-12, windows-2022 ] +# runs-on: ${{ matrix.os }} +# needs: [ fast-tests ] +# steps: +# - uses: actions/checkout@v4 +# - name: Integration tests - Examples +# run: | +# cd examples +# python test.py +# - name: Integration tests - Examples with legacy WORKSPACE setup +# run: | +# cd examples +# python test.py --legacy-workspace diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 93a77d04..b40e9cb7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -36,5 +36,5 @@ repos: hooks: - id: ruff-format # Linting - - id: ruff - args: [ --fix ] +# - id: ruff +# args: [ --fix ] diff --git a/test/aspect/execution_logic.py b/test/aspect/execution_logic.py index e789f7b9..dd1ff0a3 100644 --- a/test/aspect/execution_logic.py +++ b/test/aspect/execution_logic.py @@ -3,7 +3,6 @@ import logging import subprocess from importlib.machinery import SourceFileLoader -from os import environ from pathlib import Path from result import Error @@ -37,7 +36,15 @@ def execute_test(test: TestCaseBase, version: TestedVersions, output_base: Path, def get_current_workspace() -> Path: - process = subprocess.run(["bazel", "info", "workspace"], check=True, capture_output=True, text=True) + try: + process = subprocess.run(["bazel", "info", "workspace"], check=True, capture_output=True, text=True) + except Exception: + print("BAZEL INFO FAILED") + print("---- stdout ----") + print(process.stdout) + print("---- stderr ----") + print(process.stderr) + print("----------------") return Path(process.stdout.strip()) @@ -72,7 +79,7 @@ def main( versions = [TestedVersions(bazel=bazel, python=python)] if bazel and python else tested_versions failed_tests = [] - output_root = Path(environ["HOME"]) / ".cache" / "bazel" / workspace_path.relative_to("/") + output_root = Path.home() / ".cache" / "bazel" / "dwyu" for version in versions: output_base = output_root / f"aspect_integration_tests_bazel_{version.bazel}_python_{version.python}" output_base.mkdir(parents=True, exist_ok=True)