@@ -3,17 +3,17 @@ name: Tests
3
3
on :
4
4
push :
5
5
paths :
6
- - .github/workflows/tests.yaml
7
- - pyproject.toml
8
- - poetry.lock
9
- - tsdfileapi/**
6
+ - .github/workflows/tests.yaml
7
+ - pyproject.toml
8
+ - poetry.lock
9
+ - tsdfileapi/**
10
10
pull_request :
11
11
types : [opened, reopened, synchronize]
12
12
paths :
13
- - .github/workflows/tests.yaml
14
- - pyproject.toml
15
- - poetry.lock
16
- - tsdfileapi/**
13
+ - .github/workflows/tests.yaml
14
+ - pyproject.toml
15
+ - poetry.lock
16
+ - tsdfileapi/**
17
17
18
18
env :
19
19
TSD_FILE_API_DB_NAME : tsd_file_api_db
28
28
strategy :
29
29
fail-fast : false
30
30
matrix :
31
- python-version : ["3.8", "3. 9", "3.10", "3.11", "3.12"]
31
+ python-version : ["3.9", "3.10", "3.11", "3.12"]
32
32
33
33
services :
34
34
postgres :
@@ -38,62 +38,41 @@ jobs:
38
38
POSTGRES_USER : ${{env.TSD_FILE_API_DB_USER}}
39
39
POSTGRES_PASSWORD : ${{env.TSD_FILE_API_DB_PASS}}
40
40
options : >-
41
- --health-cmd pg_isready
42
- --health-interval 10s
43
- --health-timeout 5s
44
- --health-retries 5
41
+ --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
45
42
ports :
46
- - 5432:5432
43
+ - 5432:5432
47
44
48
45
steps :
49
- - name : Check out repository
50
- uses : actions/checkout@v4
51
- - name : Set container tag to variable
52
- run : echo "CONTAINER_TAG=tsd-file-api:${{ github.sha }}-py${{ matrix.python-version }}-r${{ github.run_attempt }}" >> $GITHUB_ENV
53
- - name : Build test container image
54
- run : >
55
- docker build
56
- --tag "${{ env.CONTAINER_TAG }}"
57
- --build-arg PYTHON_VERSION="${{ matrix.python-version }}"
58
- --build-arg POETRY_VERSION="${{env.POETRY_VERSION}}"
59
- -f "./containers/test/Dockerfile"
60
- .
61
- - name : Start tsd-file-api container and run tests (SQLite backend)
62
- run : >
63
- docker run -d
64
- -v $PWD:/file-api:ro
65
- --name tsd-file-api-sqlite
66
- --health-cmd "curl --fail http://127.0.0.1:3003/v1/all/config || exit 1"
67
- --health-interval=2s
68
- "${{ env.CONTAINER_TAG }}" && sleep 1 &&
69
- until [ "$(docker inspect -f {{.State.Health.Status}} tsd-file-api-sqlite)" == "healthy" ]; do
70
- if [ "$(docker inspect -f {{.State.Running}} tsd-file-api-sqlite)" == "false" ]; then
71
- echo "The tsd-file-api container appears to have crashed."
72
- exit 1
73
- else
74
- sleep 0.1
75
- fi; done &&
76
- docker exec tsd-file-api-sqlite python tsdfileapi/test_file_api.py
77
- - name : Log tsd-file-api (SQLite backend) container output on failure
78
- if : ${{ failure() }}
79
- run : docker logs tsd-file-api-sqlite
80
- - name : Start tsd-file-api container and run tests (PostgreSQL backend)
81
- run : >
82
- docker run -d
83
- -v $PWD:/file-api:ro
84
- --name tsd-file-api-postgres
85
- --health-cmd "curl --fail http://127.0.0.1:3003/v1/all/config || exit 1"
86
- --health-interval=2s
87
- "${{ env.CONTAINER_TAG }}"
88
- tsdfileapi/config/config-test-container-postgres.yaml && sleep 1 &&
89
- until [ "$(docker inspect -f {{.State.Health.Status}} tsd-file-api-postgres)" == "healthy" ]; do
90
- if [ "$(docker inspect -f {{.State.Running}} tsd-file-api-postgres)" == "false" ]; then
91
- echo "The tsd-file-api container appears to have crashed."
92
- exit 1
93
- else
94
- sleep 0.1
95
- fi; done &&
96
- docker exec tsd-file-api-postgres python tsdfileapi/test_file_api.py
97
- - name : Log tsd-file-api (PostgreSQL backend) container output on failure
98
- if : ${{ failure() }}
99
- run : docker logs tsd-file-api-postgres
46
+ - name : Check out repository
47
+ uses : actions/checkout@v4
48
+ - name : Set container tag to variable
49
+ run : echo "CONTAINER_TAG=tsd-file-api:${{ github.sha }}-py${{ matrix.python-version }}-r${{ github.run_attempt }}" >> $GITHUB_ENV
50
+ - name : Build test container image
51
+ run : >
52
+ docker build --tag "${{ env.CONTAINER_TAG }}" --build-arg PYTHON_VERSION="${{ matrix.python-version }}" --build-arg POETRY_VERSION="${{env.POETRY_VERSION}}" -f "./containers/test/Dockerfile" .
53
+ - name : Start tsd-file-api container and run tests (SQLite backend)
54
+ run : >
55
+ docker run -d -v $PWD:/file-api:ro --name tsd-file-api-sqlite --health-cmd "curl --fail http://127.0.0.1:3003/v1/all/config || exit 1" --health-interval=2s "${{ env.CONTAINER_TAG }}" && sleep 1 && until [ "$(docker inspect -f {{.State.Health.Status}} tsd-file-api-sqlite)" == "healthy" ]; do
56
+ if [ "$(docker inspect -f {{.State.Running}} tsd-file-api-sqlite)" == "false" ]; then
57
+ echo "The tsd-file-api container appears to have crashed."
58
+ exit 1
59
+ else
60
+ sleep 0.1
61
+ fi; done &&
62
+ docker exec tsd-file-api-sqlite python tsdfileapi/test_file_api.py
63
+ - name : Log tsd-file-api (SQLite backend) container output on failure
64
+ if : ${{ failure() }}
65
+ run : docker logs tsd-file-api-sqlite
66
+ - name : Start tsd-file-api container and run tests (PostgreSQL backend)
67
+ run : >
68
+ docker run -d -v $PWD:/file-api:ro --name tsd-file-api-postgres --health-cmd "curl --fail http://127.0.0.1:3003/v1/all/config || exit 1" --health-interval=2s "${{ env.CONTAINER_TAG }}" tsdfileapi/config/config-test-container-postgres.yaml && sleep 1 && until [ "$(docker inspect -f {{.State.Health.Status}} tsd-file-api-postgres)" == "healthy" ]; do
69
+ if [ "$(docker inspect -f {{.State.Running}} tsd-file-api-postgres)" == "false" ]; then
70
+ echo "The tsd-file-api container appears to have crashed."
71
+ exit 1
72
+ else
73
+ sleep 0.1
74
+ fi; done &&
75
+ docker exec tsd-file-api-postgres python tsdfileapi/test_file_api.py
76
+ - name : Log tsd-file-api (PostgreSQL backend) container output on failure
77
+ if : ${{ failure() }}
78
+ run : docker logs tsd-file-api-postgres
0 commit comments