Skip to content
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

Merged
merged 4 commits into from
Sep 18, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 61 additions & 4 deletions .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Following fours steps are specifically for running automated steps which includes loading the
# Following four steps are specifically for running automated steps which includes loading the

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.

# 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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we not have to save the node-red container as well? I guess since this is an automated test, maybe not. Can you please add a comment here to clarify?

Copy link
Author

Choose a reason for hiding this comment

The 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 \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
docker compose --project-name everest-ac-demo \
docker compose --project-name everest-ac-automated-testing \

Copy link
Author

Choose a reason for hiding this comment

The 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' }}
Expand Down
Loading