Skip to content

Commit 333765a

Browse files
committed
Testdrive CI
1 parent 530ade9 commit 333765a

File tree

2 files changed

+56
-5
lines changed

2 files changed

+56
-5
lines changed

.github/workflows/docker-image.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ name: Docker image automatic build (ghcr)
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches:
6+
- '**'
67
pull_request:
7-
branches: [ master ]
8+
branches:
9+
- master
810

911
env:
1012
REGISTRY: ghcr.io
@@ -15,9 +17,17 @@ jobs:
1517
runs-on: ubuntu-latest
1618
steps:
1719
- uses: actions/checkout@v2
18-
- name: Build the Docker image (PR only)
19-
if: github.ref != 'refs/heads/master'
20-
run: docker build . --file Dockerfile --tag ${{ env.IMAGE_NAME }}:$(date +%s)
20+
- name: Set tag for testing
21+
run: |
22+
echo "TAG=$(date +%s)" >> $GITHUB_ENV
23+
- name: Build the Docker image (for testing)
24+
run: |
25+
docker build . --file Dockerfile --tag ${{ env.IMAGE_NAME }}:$TAG
26+
- name: Testdrive
27+
run: |
28+
TAG=$TAG ./testdrive.sh
29+
env:
30+
IMAGE_NAME: ${{ env.IMAGE_NAME }}
2131
- name: Login to ghcr
2232
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
2333
if: github.ref == 'refs/heads/master'

testdrive.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash -ex
2+
docker run --name gitlab-postgresql -d \
3+
--env 'DB_NAME=gitlabhq_production' \
4+
--env 'DB_USER=gitlab' --env 'DB_PASS=password' \
5+
--env 'DB_EXTENSION=pg_trgm,btree_gist' \
6+
--volume /srv/docker/gitlab/postgresql:/var/lib/postgresql \
7+
sameersbn/postgresql:14-20230628
8+
docker run --name gitlab-redis -d \
9+
--volume /srv/docker/gitlab/redis:/data \
10+
redis:6.2
11+
docker run --name gitlab \
12+
--link gitlab-postgresql:postgresql --link gitlab-redis:redisio \
13+
--publish 10022:22 --publish 10080:80 \
14+
--env 'GITLAB_PORT=10080' --env 'GITLAB_SSH_PORT=10022' \
15+
--env 'GITLAB_SECRETS_DB_KEY_BASE=long-and-random-alpha-numeric-string' \
16+
--env 'GITLAB_SECRETS_SECRET_KEY_BASE=long-and-random-alpha-numeric-string' \
17+
--env 'GITLAB_SECRETS_OTP_KEY_BASE=long-and-random-alpha-numeric-string' \
18+
--env OAUTH2_GENERIC_USTC_APP_ID=1234 \
19+
--env OAUTH2_GENERIC_USTC_APP_SECRET=example \
20+
--env 'OAUTH2_GENERIC_USTC_LABEL=example oauth' \
21+
--env OAUTH2_GENERIC_USTC_CLIENT_SITE=https://example.com \
22+
--env OAUTH2_GENERIC_USTC_CLIENT_USER_INFO_URL=/userinfo \
23+
--env OAUTH2_GENERIC_USTC_CLIENT_AUTHORIZE_URL=/authorize \
24+
--env OAUTH2_GENERIC_USTC_CLIENT_TOKEN_URL=/token \
25+
--env OAUTH2_GENERIC_USTC_ID_PATH=gid \
26+
--volume /srv/docker/gitlab/gitlab:/home/git/data \
27+
"$IMAGE_NAME":"$TAG" &
28+
echo "Please wait 4 minutes..."
29+
sleep 4m
30+
url="http://localhost:10080"
31+
status_code=$(curl --write-out '%{http_code}' --silent --output /dev/null "$url")
32+
# Check if the status code is not in the success range (200-299)
33+
if [[ $status_code -lt 200 || $status_code -gt 299 ]]; then
34+
echo "Error: Failed to access $url (status code: $status_code)"
35+
exit 1
36+
fi
37+
ret=$(docker exec -it gitlab cat /home/git/gitlab/config/gitlab.yml | grep -c 'example oauth')
38+
if [[ $ret -ne 1 ]]; then
39+
echo "Error: Failed to find 'example oauth' in gitlab.yml"
40+
exit 1
41+
fi

0 commit comments

Comments
 (0)