From 309d7d9f16c5a417d637883caacd7d49d21b419b Mon Sep 17 00:00:00 2001 From: RunDevelopment Date: Sat, 20 Apr 2024 18:27:03 +0200 Subject: [PATCH 1/2] Remove pip cache --- .github/workflows/lint.yml | 2 -- .github/workflows/test.yml | 1 - 2 files changed, 3 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 112af0f9..d4e813ae 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -25,7 +25,6 @@ jobs: - uses: actions/setup-python@v5 with: python-version: '3.11' - cache: 'pip' - uses: pre-commit/action@v3.0.0 env: RUFF_OUTPUT_FORMAT: github @@ -37,7 +36,6 @@ jobs: - uses: actions/setup-python@v5 with: python-version: '3.11' - cache: 'pip' - run: sh scripts/install.sh - run: pyright libs/ - run: pyright tests/ diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fd1f2768..d1709397 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,7 +34,6 @@ jobs: - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - cache: 'pip' - run: sh scripts/install.sh - name: Cache models id: cache-models From 05a7bb25f4a213ce26c1c0d7085579e9e1eb719f Mon Sep 17 00:00:00 2001 From: RunDevelopment Date: Sat, 20 Apr 2024 18:44:53 +0200 Subject: [PATCH 2/2] Remove Github files from cache --- .github/workflows/lint.yml | 62 +++++----- .github/workflows/release-spandrel.yml | 4 +- .../release-spandrel_extra_arches.yml | 2 +- .github/workflows/test.yml | 111 +++++++++--------- tests/util.py | 15 ++- 5 files changed, 103 insertions(+), 91 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d4e813ae..c5073527 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -4,39 +4,39 @@ name: Lint # Controls when the workflow will run on: - pull_request: - branches: ['*'] - types: - - opened - - synchronize - - closed - push: - branches: [main] + pull_request: + branches: ["*"] + types: + - opened + - synchronize + - closed + push: + branches: [main] - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: '3.11' - - uses: pre-commit/action@v3.0.0 - env: - RUFF_OUTPUT_FORMAT: github + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.11" + - uses: pre-commit/action@v3.0.0 + env: + RUFF_OUTPUT_FORMAT: github - pyright: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: '3.11' - - run: sh scripts/install.sh - - run: pyright libs/ - - run: pyright tests/ - - run: pyright scripts/ + pyright: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.11" + - run: sh scripts/install.sh + - run: pyright libs/ + - run: pyright tests/ + - run: pyright scripts/ diff --git a/.github/workflows/release-spandrel.yml b/.github/workflows/release-spandrel.yml index 52c26d78..af423bdd 100644 --- a/.github/workflows/release-spandrel.yml +++ b/.github/workflows/release-spandrel.yml @@ -17,7 +17,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.11' + python-version: "3.11" - name: Install dependencies run: sh scripts/install.sh - name: Build packages @@ -37,7 +37,7 @@ jobs: uses: actions/configure-pages@v3 - uses: actions/setup-python@v5 with: - python-version: '3.11' + python-version: "3.11" - run: sh scripts/install.sh - name: Build the website run: pydoctor --project-url=https://github.com/$GITHUB_REPOSITORY --html-viewsource-base=https://github.com/$GITHUB_REPOSITORY/tree/$GITHUB_SHA diff --git a/.github/workflows/release-spandrel_extra_arches.yml b/.github/workflows/release-spandrel_extra_arches.yml index 1528c869..78734b40 100644 --- a/.github/workflows/release-spandrel_extra_arches.yml +++ b/.github/workflows/release-spandrel_extra_arches.yml @@ -11,7 +11,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.11' + python-version: "3.11" - name: Install dependencies run: sh scripts/install.sh - name: Build packages diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d1709397..e474c783 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,62 +4,67 @@ name: Test # Controls when the workflow will run on: - pull_request: - branches: ['*'] - types: - - opened - - synchronize - - closed - paths: - - 'libs/**' - - '!libs/**/*.md' - - 'tests/**' - - '.github/workflows/**' - - 'pyproject.toml' - push: - branches: [main] + pull_request: + branches: ["*"] + types: + - opened + - synchronize + - closed + paths: + - "libs/**" + - "!libs/**/*.md" + - "tests/**" + - ".github/workflows/**" + - "pyproject.toml" + push: + branches: [main] - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: - test: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ['3.8', '3.9', '3.10', '3.11'] - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - run: sh scripts/install.sh - - name: Cache models - id: cache-models - uses: actions/cache@v3 - with: - path: tests/models - key: update-2023-11-29 - - run: pytest tests + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11"] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - run: sh scripts/install.sh + - name: Cache models + id: cache-models + uses: actions/cache@v3 + with: + path: tests/models + key: update-2023-11-29 + - run: pytest tests + - name: Remove models downloaded from GitHub + run: | + touch tests/_github_files.txt + echo "Files removed from cache:" + cat tests/_github_files.txt + xargs rm < tests/_github_files.txt - docs: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: '3.11' - - run: sh scripts/install.sh - - run: pydoctor - - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: '3.11' - - run: sh scripts/install.sh - - run: sh scripts/build.sh + docs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.11" + - run: sh scripts/install.sh + - run: pydoctor + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.11" + - run: sh scripts/install.sh + - run: sh scripts/build.sh diff --git a/tests/util.py b/tests/util.py index ac08c33d..3fff145b 100644 --- a/tests/util.py +++ b/tests/util.py @@ -44,9 +44,11 @@ MAIN_REGISTRY.add(*EXTRA_REGISTRY) -MODEL_DIR = Path("./tests/models/") -ZIP_DIR = Path("./tests/zips/") -IMAGE_DIR = Path("./tests/images/") +TEST_DIR = Path("./tests/").resolve() +MODEL_DIR = TEST_DIR / "models" +ZIP_DIR = TEST_DIR / "zips" +IMAGE_DIR = TEST_DIR / "images" +GITHUB_FILE_LOG = TEST_DIR / "_github_files.txt" IS_CI = os.environ.get("CI") == "true" @@ -93,12 +95,17 @@ def convert_google_drive_link(url: str) -> str: def download_file(url: str, filename: Path | str) -> None: - filename = Path(filename) + filename = Path(filename).resolve() filename.parent.mkdir(exist_ok=True) url = convert_google_drive_link(url) logger.info("Downloading %s to %s", url, filename) torch.hub.download_url_to_file(url, str(filename), progress=not IS_CI) + # remember github files for later + if IS_CI and url.startswith("https://github.com/") and filename.parent == MODEL_DIR: + with open(GITHUB_FILE_LOG, "a") as f: + f.write(f"{filename.resolve()}\n") + def extract_file_from_zip( zip_path: Path | str,