-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (82 loc) · 2.81 KB
/
ci.yml
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: "CI Full Run"
on:
pull_request:
branches:
- main
- grok/*/*
push:
branches:
- main
jobs:
# Tests ci-storage tool itself.
ci-storage-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Create dummy file
run: echo "dummy" > dummy.txt
- name: Test store
uses: ./
with:
action: "store"
storage-host: ""
- name: Remove dummy file
run: rm dummy.txt
- name: Test load
uses: ./
with:
action: "load"
storage-host: ""
- name: Check that dummy file was restored
run: |
set -e
ls -la ~/ci-storage/dimikot/ci-storage
[ "$(cat dummy.txt)" = "dummy" ] || { echo "dummy.txt was not restored"; exit 1; }
# Builds and boots a self-hosted runner inside GitHub's infra. Once it's
# settled, there is a running container with one self-hosted runner waiting
# for jobs with "ci-storage-test" tag to pick up (based on Dockerfile image).
self-hosted-runner-build-and-boot-docker-container:
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
actions: write
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Start test Docker containers
run: |
ssh-keygen -t ed25519 -qf /tmp/key -N ""
export CI_STORAGE_HOST_SSH_KEY="$(cat /tmp/key)"
set -o xtrace
cd docker
# Boot ci-storage-host container. It will have a default empty slot.
docker compose up ci-storage-host -d --build
# Now boot self-hosted-runner container. It will connect to
# ci-storage-host container and load the empty slot from there, then
# register a GitHub self-hosted runner and remain waiting for jobs.
docker compose up self-hosted-runner --build
env:
GH_REPOSITORY: ${{ github.repository }}
GH_LABELS: ci-storage-test
GH_TOKEN: ${{ secrets.CI_PAT }}
# The test job with ci-storage-test tag which is initially queued, but then is
# picked up by the self-hosted-runner container booted in the previous job. In
# the end, the test job sends SIGINT to the container entrypoint.sh PID, so
# the container (based on Dockerfile image) shuts down gracefully.
self-hosted-runner-spawn-job-test:
runs-on: ["self-hosted", "ci-storage-test"]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run test job inside the self-hosted runner
run: echo "Hello, world!"
- name: Test store
uses: ./
with:
action: "store"
storage-host: "ci-storage-host"
- name: Kill self-hosted runner container
run: |
cd /home/ubuntu/actions-runner
kill -SIGINT $(cat runner.pid)