-
Notifications
You must be signed in to change notification settings - Fork 58
62 lines (52 loc) · 2.02 KB
/
Copy pathtest.yml
File metadata and controls
62 lines (52 loc) · 2.02 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
name: Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
env:
TESTCONTAINER_DOCKER_NETWORK: ganymede-tests
SKIP_SECRET_TESTS: false
jobs:
test:
runs-on: ubuntu-22.04
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set SKIP_SECRET_TESTS if running on a fork
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository && github.actor != 'dependabot[bot]' }}
run: |
echo "Actor: $GITHUB_ACTOR"
echo "Event: $GITHUB_EVENT_NAME"
echo "PR head repo: ${{ github.event.pull_request.head.repo.full_name }}"
echo "Current repo: ${{ github.repository }}"
echo "SKIP_SECRET_TESTS=true" >> $GITHUB_ENV
- name: Build test docker image
id: docker_build_test_image
uses: docker/build-push-action@v6
with:
platforms: linux/amd64
push: false
load: true
target: tests
- name: get-name
run: |
echo "REPO_NAME=$(basename ${{ github.repository }})" >> $GITHUB_ENV
- name: Create docker network
run: docker network create ${{ env.TESTCONTAINER_DOCKER_NETWORK }}
# Instead of having to manually install all dependencies, build the docker container and run tests in there
- name: Run tests
run: |
docker run \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /home/runner/work/${{ env.REPO_NAME }}/${{ env.REPO_NAME }}:/opt/app \
-e SKIP_SECRET_TESTS=${{ env.SKIP_SECRET_TESTS }} \
-e TWITCH_CLIENT_ID=${{ secrets.TWITCH_CLIENT_ID }} \
-e TWITCH_CLIENT_SECRET=${{ secrets.TWITCH_CLIENT_SECRET }} \
"${{ steps.docker_build_test_image.outputs.imageid }}" \
bash -c "cd /opt/app && make test"