-
Notifications
You must be signed in to change notification settings - Fork 7
69 lines (58 loc) · 2.03 KB
/
Copy pathpr-test.yaml
File metadata and controls
69 lines (58 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: Test suite
on:
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:
jobs:
docker-test:
runs-on: ubuntu-latest
timeout-minutes: 60
permissions:
contents: read
actions: write # needed for Buildx GHA cache
# don't run secret-using job on forked PRs
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Free disk space on runner
run: |
set -euxo pipefail
df -h
sudo rm -rf /usr/local/lib/android || true
sudo rm -rf /usr/share/dotnet || true
sudo rm -rf /opt/ghc || true
sudo rm -rf "${AGENT_TOOLSDIRECTORY:-/opt/hostedtoolcache}" || true
docker system prune -af || true
sudo apt-get clean
df -h
- name: Build image
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.ci
push: false
load: true
tags: slide2vec-ci:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Guard required secret (if needed)
if: ${{ github.event_name != 'pull_request' }} # or drop the condition if PRs from same repo need it
run: |
set -euo pipefail
test -n "${HF_TOKEN:-}" || { echo "HF_TOKEN is required but not set"; exit 1; }
- name: Run test suite in container
run: |
set -euo pipefail
docker run --rm \
-e HF_TOKEN="$HF_TOKEN" \
-v "$GITHUB_WORKSPACE:/opt/app" \
slide2vec-ci:${{ github.sha }} \
bash -lc "python -m pip install --no-cache-dir '/opt/app[prism,asap]' pytest pytest-cov && python -m pytest -q tests"