-
-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (82 loc) · 2.63 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
name: Build and test
on:
push:
pull_request:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
test:
runs-on: ubuntu-latest
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
steps:
- name: Checkout source code
uses: actions/checkout@v1
- name: Install python
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python_version }}
# - 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: Install Poetry
uses: snok/install-poetry@v1
- name: Install application dependencies
run: |
poetry config virtualenvs.in-project true --local
poetry install
- name: Run tests
run: ./check.sh
env:
PYTHON_VERSION: ${{ matrix.python_version }}
ACOUSTID_STATS_TEST_DATABASE_HOST: localhost
ACOUSTID_STATS_TEST_DATABASE_PORT: ${{ job.services.postgresql.ports['5432'] }}
ACOUSTID_STATS_TEST_DATABASE_NAME: acoustid
ACOUSTID_STATS_TEST_DATABASE_USER: acoustid
ACOUSTID_STATS_TEST_DATABASE_PASSWORD: acoustid
build-image:
runs-on: ubuntu-latest
needs: [ test ]
steps:
- name: Check out code
uses: actions/checkout@v1
- name: Log in to the Container registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}