Skip to content

Commit

Permalink
[160] Update workflows to reflect Cypress tests
Browse files Browse the repository at this point in the history
  • Loading branch information
CollinHeist committed Jul 24, 2024
1 parent 4a9b67a commit aff06d2
Show file tree
Hide file tree
Showing 5 changed files with 172 additions and 44 deletions.
78 changes: 67 additions & 11 deletions .github/workflows/docker_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,28 @@ on:
required: true
type: string
secrets:
DOCKER_HUB_USERNAME:
required: true
DOCKER_HUB_ACCESS_TOKEN:
CYPRESS_RECORD_KEY:
required: true
# DOCKER_HUB_USERNAME:
# required: true
# DOCKER_HUB_ACCESS_TOKEN:
# required: true
GH_TOKEN:
required: true

jobs:

docker:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Login to Dockerhub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
# - name: Login to Dockerhub
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKER_HUB_USERNAME }}
# password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
Expand All @@ -41,11 +44,64 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and Push
# Build container
- name: Build Container
uses: docker/build-push-action@v5
with:
push: false
load: true
tags: titlecardmaker:${{ inputs.tag }}-test

# Set up Cypress test environment
- name: Install Cypress Dependencies
run: >
sudo apt-get update &&
sudo apt-get install -y --no-install-recommends
libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev
libnss3 libxss1 libasound2 libxtst6 xauth xvfb
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm

# Launch container
- name: Launch Container
run: |
mkdir config
docker run -itd -p 4242:4242 -e TCM_TESTING=TRUE -v "./config":"/config" "titlecardmaker:${{ inputs.tag }}-test"
# Install npm and run Cypress tests
- name: Run Cypress Tests
uses: cypress-io/github-action@v6
continue-on-error: true
with:
start: npm run cy:run:report
wait-on: http://localhost:4242
# Records to Cypress Cloud
# https://docs.cypress.io/guides/cloud/projects#Set-up-a-project-to-record
record: true
parallel: false # Runs test in parallel using settings above
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}

# Parse testing pass percentage
- name: Parse Test Results
id: pass-percentage
if: always()
run: |
npx mochawesome-merge ./cypress/results/*.json > ./cypress/results/output.json
echo $(jq '.stats.passPercent' './cypress/results/output.json')
echo "PASS_PERCENTAGE=$(jq '.stats.passPercent' './cypress/results/output.json')" >> $GITHUB_OUTPUT
- name: Push Docker container if enough test passed
if: ${{ always() && fromJSON(steps.pass-percentage.outputs.PASS_PERCENTAGE) > 85 }}
uses: docker/build-push-action@v5
with:
platforms: linux/amd64,linux/arm64 # edit this if you want to build more architectures
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/titlecardmaker:${{ inputs.tag }},ghcr.io/collinheist/titlecardmaker:${{ inputs.tag }}
# tags: ${{ secrets.DOCKER_HUB_USERNAME }}/titlecardmaker:${{ inputs.tag }},ghcr.io/titlecardmaker/titlecardmaker-webui:${{ inputs.tag }},ghcr.io/titlecardmaker/titlecardmaker:${{ inputs.tag }}
tags: ghcr.io/titlecardmaker/titlecardmaker-webui:${{ inputs.tag }},ghcr.io/titlecardmaker/titlecardmaker:${{ inputs.tag }}
cache-from: type=gha
cache-to: type=gha,mode=max
85 changes: 71 additions & 14 deletions .github/workflows/docker_build_armv7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ on:
required: true
type: string
secrets:
DOCKER_HUB_USERNAME:
required: true
DOCKER_HUB_ACCESS_TOKEN:
required: true
# DOCKER_HUB_USERNAME:
# required: true
# DOCKER_HUB_ACCESS_TOKEN:
# required: true
GH_TOKEN:
required: true
CYPRESS_RECORD_KEY:
required: true

jobs:
docker:
Expand All @@ -20,11 +22,11 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Login to Dockerhub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
# - name: Login to Dockerhub
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKER_HUB_USERNAME }}
# password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
Expand All @@ -45,22 +47,77 @@ jobs:
uses: actions/cache@v4
with:
path: python-build-cache
key: ${{ runner.os }}-python-build-cache-${{ hashFiles('Pipfile.lock') }}
key: ${{ runner.os }}-python-build-cache

- name: inject python-build-cache into docker
uses: reproducible-containers/buildkit-cache-dance@v3 # v2.1.4
uses: reproducible-containers/buildkit-cache-dance@v3
with:
cache-map: |
{
"python-build-cache" : "/root/.cache"
}
- name: Build and Push
# Build container
- name: Build Container
uses: docker/build-push-action@v5
with:
file: Dockerfile.armv7
platforms: linux/arm/v7
push: false
load: true
tags: titlecardmaker:${{ inputs.tag }}-test

# Set up Cypress test environment
- name: Install Cypress Dependencies
run: >
sudo apt-get update &&
sudo apt-get install -y --no-install-recommends
libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev
libnss3 libxss1 libasound2 libxtst6 xauth xvfb
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm

# Launch container
- name: Launch Container
run: |
mkdir config
docker run -itd -p 4242:4242 -e TCM_TESTING=TRUE -v "./config":"/config" "titlecardmaker:${{ inputs.tag }}-test"
# Install npm and run Cypress tests
- name: Run Cypress Tests
uses: cypress-io/github-action@v6
continue-on-error: true
with:
start: npm run cy:run:report
wait-on: http://localhost:4242
# Records to Cypress Cloud
# https://docs.cypress.io/guides/cloud/projects#Set-up-a-project-to-record
record: true
parallel: false # Runs test in parallel using settings above
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}

# Parse testing pass percentage
- name: Parse Test Results
id: pass-percentage
if: always()
run: |
npx mochawesome-merge cypress/results/*.json > cypress/results/output.json
echo $(jq '.stats.passPercent' './cypress/results/output.json')
echo "PASS_PERCENTAGE=$(jq '.stats.passPercent' './cypress/results/output.json')" >> $GITHUB_OUTPUT
- name: Push Docker container if enough test passed
if: ${{ always() && fromJSON(steps.pass-percentage.outputs.PASS_PERCENTAGE) > 85 }}
uses: docker/build-push-action@v5
with:
platforms: linux/arm/v7 # edit this if you want to build more architectures
file: Dockerfile.armv7
platforms: linux/arm/v7
push: true
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/titlecardmaker:${{ inputs.tag }},ghcr.io/collinheist/titlecardmaker:${{ inputs.tag }}
# tags: ${{ secrets.DOCKER_HUB_USERNAME }}/titlecardmaker:${{ inputs.tag }},ghcr.io/titlecardmaker/titlecardmaker-webui:${{ inputs.tag }},ghcr.io/titlecardmaker/titlecardmaker:${{ inputs.tag }}
tags: ghcr.io/titlecardmaker/titlecardmaker-webui:${{ inputs.tag }},ghcr.io/titlecardmaker/titlecardmaker:${{ inputs.tag }}
cache-from: type=gha
cache-to: type=gha,mode=max
15 changes: 9 additions & 6 deletions .github/workflows/docker_develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ jobs:
with:
tag: develop
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
# DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
# DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}

docker-develop-armv7:
uses: ./.github/workflows/docker_build_armv7.yml
with:
tag: develop-armv7
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
# DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
# DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
36 changes: 24 additions & 12 deletions .github/workflows/docker_master.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@
name: Docker Master Release
name: Docker Main Release

on:
push:
branches: [ master ]
branches: [ main ]

jobs:
docker-master:
docker-main:
uses: ./.github/workflows/docker_build.yml
with:
tag: master
tag: main
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
# DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
# DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}

docker-master-armv7:
docker-latest:
uses: ./.github/workflows/docker_build.yml
with:
tag: latest
secrets:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
# DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
# DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}

docker-main-armv7:
uses: ./.github/workflows/docker_build_armv7.yml
with:
tag: master-armv7
tag: main-armv7
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
# DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
# DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
2 changes: 1 addition & 1 deletion modules/ref/version_webui
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.0-alpha.10.1-webui159
v2.0-alpha.10.1-webui160

0 comments on commit aff06d2

Please sign in to comment.