-
Notifications
You must be signed in to change notification settings - Fork 21
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
Changes from previous PR on Running automated tests via CICD #67
Changes from 2 commits
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 | ||||
---|---|---|---|---|---|---|
|
@@ -21,15 +21,15 @@ jobs: | |||||
strategy: | ||||||
matrix: | ||||||
include: | ||||||
- host_namespace: ghcr.io/everest/everest-demo | ||||||
image_name: manager | ||||||
context: ./manager | ||||||
- host_namespace: ghcr.io/everest/everest-demo | ||||||
image_name: mqtt-server | ||||||
context: ./mosquitto | ||||||
- host_namespace: ghcr.io/everest/everest-demo | ||||||
image_name: nodered | ||||||
context: ./nodered | ||||||
- host_namespace: ghcr.io/everest/everest-demo | ||||||
image_name: manager | ||||||
context: ./manager | ||||||
|
||||||
steps: | ||||||
- name: Checkout | ||||||
|
@@ -93,9 +93,66 @@ jobs: | |||||
registry: ghcr.io | ||||||
username: ${{ github.actor }} | ||||||
password: ${{ secrets.GITHUB_TOKEN }} | ||||||
|
||||||
- name: Build and export to Docker | ||||||
uses: docker/build-push-action@v6 | ||||||
with: | ||||||
load: true | ||||||
context: ${{ matrix.context }} | ||||||
push: false | ||||||
tags: ${{ steps.meta.outputs.tags }} | ||||||
labels: ${{ steps.meta.outputs.labels }} | ||||||
cache-from: type=gha,scope=${{ matrix.image_name }} | ||||||
cache-to: type=gha,mode=max,scope=${{ matrix.image_name }} | ||||||
|
||||||
# Following fours steps are specifically for running automated steps which includes loading the | ||||||
# mqtt-server image from the GitHub Actions Cache so that the docker compose automated tests can | ||||||
# use this already built image instead of pulling it from GitHub Container Registry | ||||||
- name: Save Docker image | ||||||
if: ${{ matrix.image_name == 'mqtt-server' }} | ||||||
id: save-mqtt-image | ||||||
shell: bash | ||||||
run: | | ||||||
Comment on lines
+114
to
+117
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. do we not have to save the 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. Added comment. |
||||||
echo "TAG=${{ steps.docker-image-version-check.outputs.TAG }}" | ||||||
docker save --output /tmp/mqtt-server_${{ steps.docker-image-version-check.outputs.TAG }}.tar ghcr.io/everest/everest-demo/mqtt-server:${{ steps.docker-image-version-check.outputs.TAG }} | ||||||
|
||||||
- name: Upload mqtt-server image as Artifact | ||||||
if: ${{ matrix.image_name == 'mqtt-server' }} | ||||||
uses: actions/upload-artifact@v4 | ||||||
with: | ||||||
name: mqtt_server_image_${{ steps.docker-image-version-check.outputs.TAG }} | ||||||
path: /tmp/mqtt-server_${{ steps.docker-image-version-check.outputs.TAG }}.tar | ||||||
overwrite: true | ||||||
|
||||||
- name: Download mqtt-server image as Artifact | ||||||
if: ${{ matrix.image_name == 'manager' }} | ||||||
uses: actions/download-artifact@v4 | ||||||
with: | ||||||
name: mqtt_server_image_${{ steps.docker-image-version-check.outputs.TAG }} | ||||||
path: /tmp | ||||||
|
||||||
- name: Load Docker image | ||||||
if: ${{ matrix.image_name == 'manager' }} | ||||||
id: load-mqtt-image | ||||||
shell: bash | ||||||
run: | | ||||||
docker load --input /tmp/mqtt-server_${{ steps.docker-image-version-check.outputs.TAG }}.tar | ||||||
|
||||||
- name: Run automated tests using docker-compose.automated-tests.yml | ||||||
if: ${{ matrix.image_name == 'manager' }} | ||||||
run: | | ||||||
docker images | ||||||
echo "Running docker compose up..." | ||||||
docker compose --project-name everest-ac-demo \ | ||||||
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.
Suggested change
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. Modified. |
||||||
--file "docker-compose.automated-tests.yml" up \ | ||||||
--abort-on-container-exit \ | ||||||
--exit-code-from manager | ||||||
|
||||||
exit_code=$? | ||||||
echo "Docker-compose up exit code from manager service: $exit_code" | ||||||
|
||||||
- name: Build and push | ||||||
uses: docker/build-push-action@v5 | ||||||
uses: docker/build-push-action@v6 | ||||||
with: | ||||||
context: ${{ matrix.context }} | ||||||
push: ${{ github.event_name != 'pull_request' }} | ||||||
|
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.
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.
Changed.