-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (101 loc) · 3.4 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: CI
run-name: ${{ github.actor }} is running ${{ github.workflow }} on commit ${{ github.sha }} for branch ${{ github.ref }}
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
DOCKER_TAG: ${{ secrets.DOCKER_USERNAME }}/team8:${{ github.sha }}
IS_PUSH_TO_MAIN: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
jobs:
build:
name: Build and push Docker image
runs-on: ubuntu-latest
concurrency:
group: build-${{ github.sha }}
cancel-in-progress: true
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
if: ${{ env.IS_PUSH_TO_MAIN }}
uses: docker/login-action@v3
with:
username: ${{ env.DOCKER_USERNAME }}
password: ${{ env.DOCKER_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ env.DOCKER_TAG }}
cache-from: type=registry,ref=${{ env.DOCKER_TAG }}
cache-to: type=inline
lint:
name: Lint code - Code style check
runs-on: ubuntu-latest
needs: build
concurrency:
group: lint-${{ github.sha }}
cancel-in-progress: true
steps:
- name: Run linter on workspace backend
id: backend
run: docker run ${{ env.DOCKER_TAG }} yarn workspace @team8/backend lint
- name: Run linter on workspace frontend
id: frontend
run: docker run ${{ env.DOCKER_TAG }} yarn workspace @team8/frontend lint
- name: Run linter on workspace types
id: types
run: docker run ${{ env.DOCKER_TAG }} yarn workspace @team8/types lint
- name: Run linter on workspace constants
id: constants
run: docker run ${{ env.DOCKER_TAG }} yarn workspace @team8/constants lint
- name: Run linter on workspace utils
id: utils
run: docker run ${{ env.DOCKER_TAG }} yarn workspace @team8/utils lint
tests-unit-backend:
name: Run unit tests on workspace backend
runs-on: ubuntu-latest
needs: build
concurrency:
group: tests-unit-backend-${{ github.sha }}
cancel-in-progress: true
steps:
- name: Run unit tests on workspace backend
id: backend
run: docker run ${{ env.DOCKER_TAG }} yarn workspace @team8/backend test:unit
tests-unit-frontend:
name: Run unit tests on workspace frontend
runs-on: ubuntu-latest
needs: build
concurrency:
group: tests-unit-frontend-${{ github.sha }}
cancel-in-progress: true
steps:
- name: Run unit tests on workspace frontend
id: frontend
run: docker run ${{ env.DOCKER_TAG }} yarn workspace @team8/frontend test:unit
tests-backend-e2e:
name: Run integration tests on workspace backend
runs-on: ubuntu-latest
needs: build
continue-on-error: true
concurrency:
group: tests-backend-e2e-${{ github.sha }}
cancel-in-progress: true
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker
uses: docker/setup-buildx-action@v3
- name: Run e2e tests on workspace backend
id: backend
run: docker-compose up run apps-dev yarn workspace @team8/backend test:e2e