Skip to content

Commit b6b8e2c

Browse files
authored
refactor: tilde-expansion tests as unittests and no self-hosted tests (#760)
1 parent e31bec8 commit b6b8e2c

File tree

2 files changed

+54
-124
lines changed

2 files changed

+54
-124
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -293,28 +293,6 @@ jobs:
293293
- run: uv tool install ruff
294294
- run: ruff --version
295295

296-
test-tilde-expansion-tool-dirs:
297-
runs-on: selfhosted-ubuntu-arm64
298-
steps:
299-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
300-
with:
301-
persist-credentials: false
302-
- name: Setup with cache
303-
uses: ./
304-
with:
305-
tool-bin-dir: "~/tool-bin-dir"
306-
tool-dir: "~/tool-dir"
307-
- name: "Check if tool dirs are expanded"
308-
run: |
309-
if ! echo "$PATH" | grep -q "/home/ubuntu/tool-bin-dir"; then
310-
echo "PATH does not contain /home/ubuntu/tool-bin-dir: $PATH"
311-
exit 1
312-
fi
313-
if [ "$UV_TOOL_DIR" != "/home/ubuntu/tool-dir" ]; then
314-
echo "UV_TOOL_DIR does not contain /home/ubuntu/tool-dir: $UV_TOOL_DIR"
315-
exit 1
316-
fi
317-
318296
test-python-version:
319297
runs-on: ${{ matrix.os }}
320298
strategy:
@@ -507,7 +485,7 @@ jobs:
507485
strategy:
508486
matrix:
509487
enable-cache: ["true", "false", "auto"]
510-
os: ["ubuntu-latest", "selfhosted-ubuntu-arm64", "windows-latest"]
488+
os: ["ubuntu-latest", "windows-latest"]
511489
steps:
512490
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
513491
with:
@@ -525,7 +503,7 @@ jobs:
525503
strategy:
526504
matrix:
527505
enable-cache: ["true", "false", "auto"]
528-
os: ["ubuntu-latest", "selfhosted-ubuntu-arm64", "windows-latest"]
506+
os: ["ubuntu-latest", "windows-latest"]
529507
needs: test-setup-cache
530508
steps:
531509
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -547,7 +525,7 @@ jobs:
547525
CACHE_HIT: ${{ steps.restore.outputs.cache-hit }}
548526
shell: bash
549527
- name: Cache was not hit
550-
if: ${{ matrix.enable-cache == 'false' || (matrix.enable-cache == 'auto' && matrix.os == 'selfhosted-ubuntu-arm64') }}
528+
if: ${{ matrix.enable-cache == 'false' }}
551529
run: |
552530
if [ "$CACHE_HIT" == "true" ]; then
553531
exit 1
@@ -724,8 +702,6 @@ jobs:
724702
expected-cache-dir: "/home/runner/work/_temp/setup-uv-cache"
725703
- os: windows-latest
726704
expected-cache-dir: "D:\\a\\_temp\\setup-uv-cache"
727-
- os: selfhosted-ubuntu-arm64
728-
expected-cache-dir: "/home/ubuntu/.cache/uv"
729705
runs-on: ${{ matrix.inputs.os }}
730706
steps:
731707
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -782,95 +758,6 @@ jobs:
782758
fi
783759
shell: bash
784760

785-
test-setup-cache-local:
786-
runs-on: selfhosted-ubuntu-arm64
787-
steps:
788-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
789-
with:
790-
persist-credentials: false
791-
- name: Setup with cache
792-
uses: ./
793-
with:
794-
enable-cache: true
795-
cache-suffix: ${{ github.run_id }}-${{ github.run_attempt }}-test-setup-cache-local
796-
cache-local-path: /tmp/uv-cache
797-
- run: uv sync
798-
working-directory: __tests__/fixtures/uv-project
799-
test-restore-cache-local:
800-
runs-on: selfhosted-ubuntu-arm64
801-
needs: test-setup-cache-local
802-
steps:
803-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
804-
with:
805-
persist-credentials: false
806-
- name: Restore with cache
807-
id: restore
808-
uses: ./
809-
with:
810-
enable-cache: true
811-
cache-suffix: ${{ github.run_id }}-${{ github.run_attempt }}-test-setup-cache-local
812-
cache-local-path: /tmp/uv-cache
813-
- name: Cache was hit
814-
run: |
815-
if [ "$CACHE_HIT" != "true" ]; then
816-
exit 1
817-
fi
818-
env:
819-
CACHE_HIT: ${{ steps.restore.outputs.cache-hit }}
820-
- run: uv sync
821-
working-directory: __tests__/fixtures/uv-project
822-
823-
test-tilde-expansion-cache-local-path:
824-
runs-on: selfhosted-ubuntu-arm64
825-
steps:
826-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
827-
with:
828-
persist-credentials: false
829-
- name: Create cache directory
830-
run: mkdir -p ~/uv-cache
831-
shell: bash
832-
- name: Setup with cache
833-
uses: ./
834-
with:
835-
cache-local-path: ~/uv-cache/cache-local-path
836-
- run: uv sync
837-
working-directory: __tests__/fixtures/uv-project
838-
839-
test-tilde-expansion-cache-dependency-glob:
840-
runs-on: selfhosted-ubuntu-arm64
841-
steps:
842-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
843-
with:
844-
persist-credentials: false
845-
- name: Create cache directory
846-
run: mkdir -p ~/uv-cache
847-
shell: bash
848-
- name: Create cache dependency glob file
849-
run: touch ~/uv-cache.glob
850-
shell: bash
851-
- name: Setup with cache
852-
uses: ./
853-
with:
854-
enable-cache: true
855-
cache-local-path: ~/uv-cache/cache-dependency-glob
856-
cache-dependency-glob: "~/uv-cache.glob"
857-
- run: uv sync
858-
working-directory: __tests__/fixtures/uv-project
859-
860-
cleanup-tilde-expansion-tests:
861-
needs:
862-
- test-tilde-expansion-cache-local-path
863-
- test-tilde-expansion-cache-dependency-glob
864-
if: always()
865-
runs-on: selfhosted-ubuntu-arm64
866-
steps:
867-
- name: Remove cache directory
868-
run: rm -rf ~/uv-cache
869-
shell: bash
870-
- name: Remove cache dependency glob file
871-
run: rm -f ~/uv-cache.glob
872-
shell: bash
873-
874761
test-no-python-version:
875762
runs-on: ubuntu-latest
876763
steps:
@@ -1061,8 +948,6 @@ jobs:
1061948
expected-python-dir: "/home/runner/work/_temp/uv-python-dir"
1062949
- os: windows-latest
1063950
expected-python-dir: "D:\\a\\_temp\\uv-python-dir"
1064-
- os: selfhosted-ubuntu-arm64
1065-
expected-python-dir: "/home/ubuntu/.local/share/uv/python"
1066951
runs-on: ${{ matrix.inputs.os }}
1067952
steps:
1068953
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -1120,7 +1005,6 @@ jobs:
11201005
- test-with-explicit-token
11211006
- test-uvx
11221007
- test-tool-install
1123-
- test-tilde-expansion-tool-dirs
11241008
- test-python-version
11251009
- test-activate-environment
11261010
- test-activate-environment-custom-path
@@ -1139,11 +1023,6 @@ jobs:
11391023
- test-restore-cache-save-cache-false
11401024
- test-setup-cache-restore-cache-false
11411025
- test-restore-cache-restore-cache-false
1142-
- test-setup-cache-local
1143-
- test-restore-cache-local
1144-
- test-tilde-expansion-cache-local-path
1145-
- test-tilde-expansion-cache-dependency-glob
1146-
- cleanup-tilde-expansion-tests
11471026
- test-no-python-version
11481027
- test-custom-manifest-file
11491028
- test-absolute-path

__tests__/utils/inputs.test.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,57 @@ describe("cacheDependencyGlob", () => {
8787
});
8888
});
8989

90+
describe("tool directories", () => {
91+
beforeEach(() => {
92+
jest.resetModules();
93+
jest.clearAllMocks();
94+
mockInputs = {};
95+
process.env.HOME = "/home/testuser";
96+
});
97+
98+
afterEach(() => {
99+
process.env.HOME = ORIGINAL_HOME;
100+
});
101+
102+
it("expands tilde for tool-bin-dir and tool-dir", async () => {
103+
mockInputs["working-directory"] = "/workspace";
104+
mockInputs["tool-bin-dir"] = "~/tool-bin-dir";
105+
mockInputs["tool-dir"] = "~/tool-dir";
106+
107+
const { toolBinDir, toolDir } = await import("../../src/utils/inputs");
108+
109+
expect(toolBinDir).toBe("/home/testuser/tool-bin-dir");
110+
expect(toolDir).toBe("/home/testuser/tool-dir");
111+
});
112+
});
113+
114+
describe("cacheLocalPath", () => {
115+
beforeEach(() => {
116+
jest.resetModules();
117+
jest.clearAllMocks();
118+
mockInputs = {};
119+
process.env.HOME = "/home/testuser";
120+
});
121+
122+
afterEach(() => {
123+
process.env.HOME = ORIGINAL_HOME;
124+
});
125+
126+
it("expands tilde in cache-local-path", async () => {
127+
mockInputs["working-directory"] = "/workspace";
128+
mockInputs["cache-local-path"] = "~/uv-cache/cache-local-path";
129+
130+
const { CacheLocalSource, cacheLocalPath } = await import(
131+
"../../src/utils/inputs"
132+
);
133+
134+
expect(cacheLocalPath).toEqual({
135+
path: "/home/testuser/uv-cache/cache-local-path",
136+
source: CacheLocalSource.Input,
137+
});
138+
});
139+
});
140+
90141
describe("venvPath", () => {
91142
beforeEach(() => {
92143
jest.resetModules();

0 commit comments

Comments
 (0)