-
Notifications
You must be signed in to change notification settings - Fork 21
137 lines (117 loc) · 4.46 KB
/
build.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
name: Build and test
on:
push:
pull_request:
env:
REGISTRY: quay.io
IMAGE_NAME: acoustid/acoustid-server
jobs:
test:
runs-on: ubuntu-22.04
strategy:
matrix:
python_version: [ '3.10' ]
services:
postgresql:
image: quay.io/acoustid/postgresql:master
ports:
- 5432/tcp
env:
POSTGRES_USER: acoustid
POSTGRES_PASSWORD: acoustid
POSTGRES_DB: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis
ports:
- 6379/tcp
index:
image: quay.io/acoustid/acoustid-index:2018.01.13
ports:
- 6080/tcp
steps:
- name: Checkout source code
uses: actions/checkout@v3
- name: Install python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python_version }}
cache: pip
cache-dependency-path: requirements*.txt
- name: Install tox
run: pip install tox
- name: Lint on the source code
run: |
tox -e flake8,mypy,isort,black
env:
PYTHON_VERSION: ${{ matrix.python_version }}
- name: Install additional requirements
run: |
sudo apt-get update
sudo apt-get install libchromaprint1 libpq-dev
- name: Setup database
run: |
container=$(docker ps -q -f expose=5432)
docker exec -i -e PGUSER=$PGUSER -e PGPASSWORD=$PGPASSWORD -e PGDATABASE=$PGDATABASE $container psql < ./admin/ci/create_db.sql
env:
PGUSER: acoustid
PGPASSWORD: acoustid
PGDATABASE: postgres
- name: Run tests
run: |
tox -e py${{ matrix.python_version }}
env:
PYTHON_VERSION: ${{ matrix.python_version }}
ACOUSTID_TEST_DATABASE_APP_HOST: localhost
ACOUSTID_TEST_DATABASE_APP_PORT: ${{ job.services.postgresql.ports['5432'] }}
ACOUSTID_TEST_DATABASE_APP_RO_HOST: localhost
ACOUSTID_TEST_DATABASE_APP_RO_PORT: ${{ job.services.postgresql.ports['5432'] }}
ACOUSTID_TEST_DATABASE_FINGERPRINT_HOST: localhost
ACOUSTID_TEST_DATABASE_FINGERPRINT_PORT: ${{ job.services.postgresql.ports['5432'] }}
ACOUSTID_TEST_DATABASE_FINGERPRINT_RO_HOST: localhost
ACOUSTID_TEST_DATABASE_FINGERPRINT_RO_PORT: ${{ job.services.postgresql.ports['5432'] }}
ACOUSTID_TEST_DATABASE_INGEST_HOST: localhost
ACOUSTID_TEST_DATABASE_INGEST_PORT: ${{ job.services.postgresql.ports['5432'] }}
ACOUSTID_TEST_DATABASE_INGEST_RO_HOST: localhost
ACOUSTID_TEST_DATABASE_INGEST_RO_PORT: ${{ job.services.postgresql.ports['5432'] }}
ACOUSTID_TEST_DATABASE_MUSICBRAINZ_HOST: localhost
ACOUSTID_TEST_DATABASE_MUSICBRAINZ_PORT: ${{ job.services.postgresql.ports['5432'] }}
ACOUSTID_TEST_DATABASE_MUSICBRAINZ_RO_HOST: localhost
ACOUSTID_TEST_DATABASE_MUSICBRAINZ_RO_PORT: ${{ job.services.postgresql.ports['5432'] }}
ACOUSTID_TEST_REDIS_HOST: localhost
ACOUSTID_TEST_REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
ACOUSTID_TEST_INDEX_HOST: localhost
ACOUSTID_TEST_INDEX_PORT: ${{ job.services.index.ports['6080'] }}
build:
runs-on: ubuntu-22.04
needs: [ test ]
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Log in to the Container registry
if: github.event_name != 'pull_request' && github.actor != 'dependabot[bot]'
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
push: ${{ github.event_name != 'pull_request' && github.actor != 'dependabot[bot]' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:master
cache-to: type=inline