-
Notifications
You must be signed in to change notification settings - Fork 17
104 lines (97 loc) · 3.69 KB
/
python-package.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
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: tests
on:
push:
branches:
- '*'
pull_request:
branches:
- '*'
jobs:
build:
runs-on: ubuntu-latest
# Service containers to run with `container-job`
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres:15
# Provide the password for postgres
env:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_HOST: localhost
PGPASSWORD: postgres
ports:
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Set up Icelandic locale
run: |
sudo locale-gen is_IS.UTF-8
sudo update-locale
- name: Install dependencies
run: |
pip install --upgrade pip wheel setuptools pytest curlylint
pip install --upgrade git+https://github.com/mideind/Tokenizer#egg=tokenizer
pip install --upgrade git+https://github.com/mideind/GreynirPackage#egg=reynir
pip install --upgrade -r requirements.txt
sudo npm i -g jshint
sudo apt-get install shellcheck
- name: Set up database
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_PORT: 5432
POSTGRES_HOST: localhost
PGPASSWORD: postgres
run: |
PGPASSWORD=postgres psql -h localhost -U postgres -c "create user reynir with password 'reynir';"
PGPASSWORD=postgres psql -h localhost -U postgres -c "create database scraper with encoding 'UTF8' TEMPLATE=template0;"
PGPASSWORD=postgres psql -h localhost -U postgres -d scraper -c "create extension if not exists \"uuid-ossp\";"
PGPASSWORD=postgres psql -h localhost -U postgres -d scraper -c "alter database scraper owner to reynir;"
python scraper.py --init
psql -f tests/files/populate_testdb.sql postgresql://postgres:postgres@localhost:5432/scraper
- name: Create API keys
run: |
cat "tests/files/dummy_greynir_api_key.txt" > "resources/GreynirServerKey.txt"
cat "tests/files/dummy_atm_data.json" > "queries/resources/isb_locations.json"
echo '${{ secrets.AWSPOLLY_KEY_JSON }}' > "resources/AWSPollyServerKey.json"
echo '${{ secrets.AZURE_KEY_JSON }}' > "resources/AzureSpeechServerKey.json"
- name: Test with pytest
run: |
python -m pytest
- name: Run curlylint on templates
run: |
curlylint templates/*
curlylint templates/*/*
- name: Run jshint on JavaScript files
run: |
jshint static/js/common.js
jshint --prereq static/js/common.js static/js/page.js
- name: Run shellcheck on shell scripts
run: |
shellcheck -x scripts/*.sh
- name: Slack notification
uses: 8398a7/action-slack@v2
with:
status: ${{ job.status }}
author_name: Integration Testing (Python ${{ matrix.python-version }})
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
if: failure() # Pick up event if the job fails