-
Notifications
You must be signed in to change notification settings - Fork 7
136 lines (131 loc) · 4.43 KB
/
test.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
name: Build and Test
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: "Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)"
required: false
default: false
env:
MATERIAL_REPO: "UNIVERSE-HPC/course-material"
MANAGER: "yarn"
jobs:
build-and-test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
env:
MATERIAL_DIR: ".material"
NEXT_PUBLIC_BASEPATH: ""
NEXTAUTH_URL: http://localhost:3002/gutenberg/api/auth
NEXTAUTH_SECRET: "secret here"
GITHUB_SECRET: "github_secret"
GITHUB_ID: "github_id"
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/gutenberg
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Enable corepack
shell: bash
run: corepack enable
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
cache: ${{ env.MANAGER }}
- name: Restore cache
uses: actions/cache@v4
with:
path: |
.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
- name: Install dependencies
run: ${{ env.MANAGER }} install
- name: Migrate database
run: ${{ env.MANAGER }} prisma migrate deploy
- name: Seed database with test data
run: ${{ env.MANAGER }} prisma db seed
- name: Checkout course material
shell: bash
run: yarn pullmat
- name: Check course material
shell: bash
run: ls ${{ env.MATERIAL_DIR }}
- name: Build with Next.js
run: ${{ env.MANAGER }} build
# Enable tmate debugging of manually-triggered workflows if the input option was provided
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
- name: Run e2e tests
run: ${{ env.MANAGER }} ci:e2e
- name: Run component tests
run: ${{ env.MANAGER }} component
docker-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: docker compose build
run: docker compose -f docker-compose.yml build
- name: docker compose up
run: docker compose -f docker-compose.yml up -d
- name: docker compose ps
run: docker compose -f docker-compose.yml ps
- name: docker compose down
run: docker compose -f docker-compose.yml down
deploy:
name: Deploy to staging
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
needs: build-and-test
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Enable corepack
shell: bash
run: corepack enable
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Checkout course material
shell: bash
run: |
pip install --upgrade pip setuptools wheel
pip install -r scripts/python_requirements.txt
python scripts/pull_material.py
- name: Check course material
shell: bash
run: ls ${{ env.MATERIAL_DIR }}
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy -a gutenberg-staging --remote-only
--build-arg DATABASE_URL=${{secrets.DATABASE_URL_TEST}}
--build-arg NEXT_PUBLIC_PLAUSIBLE_DOMAIN=${{secrets.NEXT_PUBLIC_PLAUSIBLE_DOMAIN_TEST}}
--wait-timeout 240
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
NEXT_PUBLIC_PLAUSIBLE_DOMAIN: ${{ secrets.NEXT_PUBLIC_PLAUSIBLE_DOMAIN }}