-
Notifications
You must be signed in to change notification settings - Fork 2
155 lines (130 loc) · 4.65 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
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: CI
on: [push]
jobs:
python-tests:
runs-on: ubuntu-22.04
services:
# Label used to access the service container
db:
# Docker Hub image
image: postgres:12.19
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres # pragma: allowlist secret
POSTGRES_DB: postgres
ports:
- 5432:5432
redis:
image: redis:5.0.14
ports:
- 6379:6379
elastic:
image: docker.elastic.co/elasticsearch/elasticsearch:7.17.21
env:
network.host: "0.0.0.0"
http.cors.enabled: "true"
http.cors.allow-origin: "*"
http.max_content_length: "10mb"
rest.action.multi.allow_explicit_index: "false"
ES_JAVA_OPTS: "-Xms1024m -Xmx1024m"
discovery.type: "single-node"
ports:
- 9200:9200
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
- name: update apt
run: sudo apt-get update -y
- name: Apt install
run: cat Aptfile | sudo xargs apt-get install
- name: Install poetry
uses: snok/install-poetry@93ada01c735cc8a383ce0ce2ae205a21c415379b # v1
with:
version: 1.5.1
virtualenvs-create: true
virtualenvs-in-project: true
- uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4
with:
python-version: '3.11.4'
cache: 'poetry'
- name: Install dependencies
run: poetry install --no-interaction
- name: Code formatting
run: poetry run black --check .
- name: Lint
run: poetry run pylint ./**/*.py
- name: Create test local state
run: ./scripts/test/stub-data.sh
- name: Tests
run: |
export MEDIA_ROOT="$(mktemp -d)"
./scripts/test/python_tests.sh
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres # pragma: allowlist secret
OPEN_DISCUSSIONS_SECURE_SSL_REDIRECT: 'False'
OPEN_DISCUSSIONS_DB_DISABLE_SSL: 'True'
OPEN_DISCUSSIONS_FEATURES_DEFAULT: 'True'
OPEN_DISCUSSIONS_REDDIT_URL: https://reddit.local
OPEN_DISCUSSIONS_REDDIT_VALIDATE_SSL: 'False'
OPEN_DISCUSSIONS_REDDIT_CLIENT_ID: od_client_id
OPEN_DISCUSSIONS_REDDIT_SECRET: od_client_secret # pragma: allowlist secret
OPENSEARCH_URL: localhost:9200
CELERY_TASK_ALWAYS_EAGER: 'True'
CELERY_BROKER_URL: redis://localhost:6379/4
CELERY_RESULT_BACKEND: redis://localhost:6379/4
TIKA_CLIENT_ONLY: 'True'
AKISMET_IS_TESTING: 'True'
OPEN_DISCUSSIONS_BASE_URL: http://localhost:8063/
MAILGUN_KEY: fake_mailgun_key
MAILGUN_SENDER_DOMAIN: other.fake.site
OPENSEARCH_INDEX: testindex
INDEXING_API_USERNAME: mitodl
OPEN_DISCUSSIONS_COOKIE_DOMAIN: localhost
OPEN_DISCUSSIONS_COOKIE_NAME: cookie_monster
- name: Upload coverage to CodeCov
uses: codecov/codecov-action@29386c70ef20e286228c72b668a06fd0e8399192 # v1
with:
file: ./coverage.xml
javascript-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
- uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3
with:
node-version: '16.15.1'
cache: 'yarn'
- name: Setup environment
run: sudo apt-get install libelf1
- name: Install dependencies
run: yarn install --immutable
- name: Webpack build
run: yarn run build
- name: Lints
run: yarn run lint-check
- name: Code formatting
run: yarn run fmt-check
- name: Scss lint
run: yarn run scss-lint
- name: Typecheck
run: yarn run typecheck
- name: Tests (old; mocha)
run: yarn workspace open-discussions run test
env:
NODE_ENV: test
- name: Get number of CPU cores
id: cpu-cores
uses: SimenB/github-actions-cpu-cores@410541432439795d30db6501fb1d8178eb41e502 # v1
- name: Tests
run: yarn test --max-workers ${{ steps.cpu-cores.outputs.count }}
env:
CODECOV: true
NODE_ENV: test
- name: Upload coverage to CodeCov
uses: codecov/codecov-action@29386c70ef20e286228c72b668a06fd0e8399192 # v1
with:
file: coverage/lcov.info