-
Notifications
You must be signed in to change notification settings - Fork 345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add runtime check, runtime logs and build logs #293
Changes from 32 commits
fa788cf
d299d9a
fe5c310
2b54576
9a74219
ff56a03
a049989
5f2a14b
5dbfc57
d4e0fce
42e1b72
83d34f8
3161242
1cb1dec
bcdff6e
4870434
933f472
92512fd
a1d56a1
26784d6
8353418
bd8a941
ff0db3a
89bd10b
0048a58
008ddd5
f7885ee
d17064f
4be3f45
a23fd8b
04e4c64
34c213f
87379fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,13 @@ on: | |
types: | ||
- completed | ||
# Allow running workflow manually from the Actions tab | ||
# workflow_dispatch: | ||
workflow_dispatch: | ||
# Uncomment below to allow specific version workflow run | ||
# inputs: | ||
# version: | ||
# description: 'Version to build' | ||
# required: true | ||
|
||
# Leaving in example for releases. Initially we simply push to 'latest' | ||
# on: | ||
|
@@ -32,7 +38,12 @@ jobs: | |
|
||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it, uncomment below | ||
# - name: Checkout code at specified version | ||
# uses: actions/checkout@v2 | ||
# with: | ||
# ref: ${{ github.event.inputs.version }} | ||
|
||
- name: checkout | ||
uses: actions/checkout@v3 | ||
|
||
|
@@ -91,14 +102,15 @@ jobs: | |
# config-inline: | | ||
# [worker.oci] | ||
# max-parallelism = 1 | ||
- name: Build and push image | ||
|
||
- name: Build image | ||
id: docker_build | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: ./ | ||
file: ./Dockerfile | ||
push: ${{ github.event_name != 'pull_request' }} | ||
load: true # Load the image into the Docker daemon | ||
push: false # Do not push the image at this stage | ||
platforms: linux/amd64 | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
@@ -107,11 +119,61 @@ jobs: | |
NEXT_PUBLIC_LICENSE_CONSENT=${{ env.NEXT_PUBLIC_LICENSE_CONSENT }} | ||
NEXT_PUBLIC_TELEMETRY_KEY=${{ env.NEXT_PUBLIC_TELEMETRY_KEY }} | ||
DATABASE_URL=postgresql://${{ env.POSTGRES_USER }}:${{ env.POSTGRES_PASSWORD }}@${{ env.DATABASE_HOST }}/${{ env.POSTGRES_DB }} | ||
|
||
# - name: Build with docker compose | ||
# run: | | ||
# DOCKER_BUILDKIT=0 docker compose build --build-arg DATABASE_URL=postgresql://${{ env.POSTGRES_USER }}:${{ env.POSTGRES_PASSWORD }}@${{ env.DATABASE_HOST }}/${{ env.POSTGRES_DB }} calcom | ||
|
||
- name: Test runtime | ||
run: | | ||
tags="${{ steps.meta.outputs.tags }}" | ||
IFS=',' read -ra ADDR <<< "$tags" # Convert string to array using ',' as delimiter | ||
tag=${ADDR[0]} # Get the first tag | ||
|
||
docker run --rm --network stack \ | ||
-p 3000:3000 \ | ||
-e DATABASE_URL=postgresql://${{ env.POSTGRES_USER }}:${{ env.POSTGRES_PASSWORD }}@database/${{ env.POSTGRES_DB }} \ | ||
-e NEXTAUTH_SECRET=${{ env.NEXTAUTH_SECRET }} \ | ||
-e CALENDSO_ENCRYPTION_KEY=${{ env.CALENDSO_ENCRYPTION_KEY }} \ | ||
$tag & | ||
|
||
server_pid=$! | ||
|
||
|
||
echo "Waiting for the server to start..." | ||
sleep 120 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We give 120 seconds for the server to be ready to accept curl request. It was erroring out with code 7 if we requested when it wasn't ready. |
||
|
||
echo ${{ env.NEXT_PUBLIC_WEBAPP_URL }}/auth/login | ||
|
||
for i in {1..60}; do | ||
echo "Checking server health ($i/60)..." | ||
response=$(curl -o /dev/null -s -w "%{http_code}" ${{ env.NEXT_PUBLIC_WEBAPP_URL }}/auth/login) | ||
echo "HTTP Status Code: $response" | ||
if [[ "$response" == "200" ]] || [[ "$response" == "307" ]]; then | ||
echo "Server is healthy" | ||
# Now, shutdown the server | ||
kill $server_pid | ||
exit 0 | ||
fi | ||
sleep 1 | ||
done | ||
Comment on lines
+147
to
+158
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check every second until |
||
|
||
echo "Server health check failed" | ||
kill $server_pid | ||
exit 1 | ||
env: | ||
NEXTAUTH_SECRET: 'EI4qqDpcfdvf4A+0aQEEx8JjHxHSy4uWiZw/F32K+pA=' | ||
CALENDSO_ENCRYPTION_KEY: '0zfLtY99wjeLnsM7qsa8xsT+Q0oSgnOL' | ||
Comment on lines
+164
to
+165
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not entirely sure if it's better to pass these from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's probably save since these are just arbitrary test values in this case |
||
|
||
- name: Push image | ||
run: | | ||
tags="${{ steps.meta.outputs.tags }}" | ||
IFS=',' read -ra ADDR <<< "$tags" # Convert string to array using ',' as delimiter | ||
tag=${ADDR[0]} # Get the first tag | ||
|
||
docker push $tag | ||
Comment on lines
+167
to
+173
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd like to check in a future PR if it's better to reuse the docker/build-push-action like in the example. It should't rebuild but that isn't clear in the docs I linked. |
||
|
||
|
||
- name: Cleanup | ||
run: | | ||
docker compose down | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be beneficial in the future to test the workflow run against specific versions for a more targeted debugging
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good with adding this commented. would be good to add an additional input to toggle pushing as well here