Merge branch 'master' of github.com:mideind/Greynir #1191
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.9"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
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 cache purge | |
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/GreynirEngine#egg=reynir | |
pip install --upgrade git+https://github.com/mideind/Icespeak#egg=icespeak | |
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: | | |
ICESPEAK_KEYS_DIR="resources/" python -m pytest -vvvrP --log-level=DEBUG | |
- 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@v3 | |
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 |