Skip to content

Commit

Permalink
Merge pull request #2 from fabianvf/global-ci-workflow
Browse files Browse the repository at this point in the history
✨ Create reusable global ci workflow
  • Loading branch information
fabianvf authored Jun 5, 2023
2 parents a64eddf + e9b169e commit d06f18a
Show file tree
Hide file tree
Showing 3 changed files with 285 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: Konveyor CI

on: ["push", "pull_request"]

jobs:
ci:
uses: ./.github/workflows/global-ci.yml
251 changes: 251 additions & 0 deletions .github/workflows/global-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
name: Run global Konveyor CI tests

on:
workflow_call:
inputs:
tag:
description: |
The tag that should be used to pull all konveyor related images.
For example, if you wanted to set a nightly build for release-0.2, you would specify
"release-0.2".
required: false
type: string
default: latest
component_name:
description: |
The name of the component being tested, ie konveyor-hub, analyzer-lsp, etc.
Must correspond to an artifact storing the custom built image, named <component_name>,
and should contain the file <component_name>.tar inside.
required: false
type: string
golang_tests_ref:
description: |
The branch or PR of the go-konveyor-tests repository to clone.
For a pull request, the reference format would be "refs/pull/${PR_NUMBER}/merge".
For a branch, the reference format would just be the branch name.
This input can be set automatically on a pull request by adding a string of the format:
Go tests PR: 140
replacing "140" with the appropriate PR number. This will make it easier to coordinate changes
that require updating the global tests as well.
required: false
type: string
default: main
ui_tests_ref:
description: |
The branch or PR of the tackle-ui-tests repository to clone.
For a pull request, the reference format would be "refs/pull/${PR_NUMBER}/merge".
For a branch, the reference format would just be the branch name.
This input can be set automatically on a pull request by adding a string of the format:
UI tests PR: 140
replacing "140" with the appropriate PR number. This will make it easier to coordinate changes
that require updating the global tests as well.
required: false
type: string
default: main
workflow_dispatch:
inputs:
tag:
description: |
The tag that should be used to pull all konveyor related images.
For example, if you wanted to set a nightly build for release-0.2, you would specify
"release-0.2".
required: false
type: string
default: latest
component_name:
description: |
The name of the component being tested, ie konveyor-hub, analyzer-lsp, etc.
Must correspond to an artifact storing the custom built image, named <component_name>,
and should contain the file <component_name>.tar inside.
required: false
type: string
golang_tests_ref:
description: |
The branch or PR of the go-konveyor-tests repository to clone.
For a pull request, the reference format would be "refs/pull/${PR_NUMBER}/merge".
For a branch, the reference format would just be the branch name.
This input can be set automatically on a pull request by adding a string of the format:
Go tests PR: 140
replacing "140" with the appropriate PR number. This will make it easier to coordinate changes
that require updating the global tests as well.
required: false
type: string
default: main
ui_tests_ref:
description: |
The branch or PR of the tackle-ui-tests repository to clone.
For a pull request, the reference format would be "refs/pull/${PR_NUMBER}/merge".
For a branch, the reference format would just be the branch name.
This input can be set automatically on a pull request by adding a string of the format:
UI tests PR: 140
replacing "140" with the appropriate PR number. This will make it easier to coordinate changes
that require updating the global tests as well.
required: false
type: string
default: main

jobs:
tackle-golang-api-tests:
runs-on: ubuntu-latest
steps:
- name: Extract pull request number from inputs or PR description
run: |
PULL_REQUEST_NUMBER=$(echo "${{ github.event.pull_request.body }}" | grep -oP '[G|g]o [T|t]ests [P|p][R|r]: \K\d+' || true)
if [ -z "$PULL_REQUEST_NUMBER" ]; then
echo "GOLANG_TESTS_REF=${{ inputs.golang_tests_ref }}" >>$GITHUB_ENV
else
echo "GOLANG_TESTS_REF=refs/pull/$PULL_REQUEST_NUMBER/merge" >>$GITHUB_ENV
fi
- name: Checkout golang api tests repo
uses: actions/checkout@v3
with:
repository: konveyor/go-konveyor-tests
path: go-konveyor-tests
ref: "${{ env.GOLANG_TESTS_REF }}"

# TODO Should DRY this
- name: set up docker buildx
if: "${{ inputs.component_name != '' }}"
uses: docker/setup-buildx-action@v2

- name: Download artifact
if: "${{ inputs.component_name != '' }}"
uses: actions/download-artifact@v3
with:
name: ${{ inputs.component_name }}
path: /tmp

- name: start minikube
uses: konveyor/tackle2-operator/.github/actions/start-minikube@main

# TODO: Could just load all images found in this artifact so that people can rebuild multiple components if needed
- name: Load image
if: "${{ inputs.component_name != '' }}"
run: |
export SHELL=/bin/bash
eval $(minikube -p minikube docker-env)
docker load --input /tmp/${{ inputs.component_name }}.tar
- name: install konveyor
uses: konveyor/tackle2-operator/.github/actions/install-tackle@main
with:
# TODO need to set the tackle-operator image once supported
# tackle-operator-image: quay.io/konveyor/tackle2-operator:${{ inputs.tag }}
tackle-hub-image: "quay.io/konveyor/tackle2-hub:${{ inputs.tag }}"
tackle-pathfinder-image: "quay.io/konveyor/tackle-pathfinder:${{ inputs.tag != 'latest' && inputs.tag || '1.3.0-native' }}"
tackle-ui-image: "quay.io/konveyor/tackle2-ui:${{ inputs.tag }}"
tackle-addon-admin-image: "quay.io/konveyor/tackle2-addon:${{ inputs.tag }}"
tackle-addon-windup-image: "quay.io/konveyor/tackle2-addon-windup:${{ inputs.tag }}"
tackle-image-pull-policy: IfNotPresent
tackle-windup-container-memory: 0
tackle-windup-container-cpu: 0
# end DRY

- uses: actions/setup-go@v4
with:
go-version: 1.18

- name: Build and run golang API tests
run: |
export HUB_BASE_URL="http://$(minikube ip)/hub"
go test -v ./analysis/...
working-directory: go-konveyor-tests

tackle-ui-tests:
# TODO once these are passing consistently within about an hour reenable for PRs
if: ${{ github.event_name != 'pull_request' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# TODO: Support cypress-split in main tackle-ui-test project
# split: [0, 1, 2, 3, 4, 5, 6, 7, 8]
tier: [tier1, tier2, tier3]
steps:

- name: Extract pull request number from inputs or PR description
run: |
PULL_REQUEST_NUMBER=$(echo "${{ github.event.pull_request.body }}" | grep -oP '[U|u][I|i] [T|t]ests [P|p][R|r]: \K\d+' || true)
if [ -z "$PULL_REQUEST_NUMBER" ]; then
echo "UI_TESTS_REF=${{ inputs.ui_tests-ref }}" >>$GITHUB_ENV
else
echo "UI_TESTS_REF=refs/pull/$PULL_REQUEST_NUMBER/merge" >>$GITHUB_ENV
fi
- name: Checkout ui tests repo
uses: actions/checkout@v3
with:
repository: konveyor/tackle-ui-tests
path: tackle-ui-tests
ref: "${{ env.UI_TESTS_REF }}"

# TODO Should DRY this
- name: set up docker buildx
if: "${{ inputs.component_name != '' }}"
uses: docker/setup-buildx-action@v2

- name: Download artifact
if: "${{ inputs.component_name != '' }}"
uses: actions/download-artifact@v3
with:
name: ${{ inputs.component_name }}
path: /tmp

- name: start minikube
uses: konveyor/tackle2-operator/.github/actions/start-minikube@main

# TODO: Could just load all images found in this artifact so that people can rebuild multiple components if needed
- name: Load image
if: "${{ inputs.component_name != '' }}"
run: |
export SHELL=/bin/bash
eval $(minikube -p minikube docker-env)
docker load --input /tmp/${{ inputs.component_name }}.tar
- name: install konveyor
uses: konveyor/tackle2-operator/.github/actions/install-tackle@main
with:
# TODO need to set the tackle-operator image once supported
# tackle-operator-image: quay.io/konveyor/tackle2-operator:${{ inputs.tag }}
tackle-hub-image: "quay.io/konveyor/tackle2-hub:${{ inputs.tag }}"
tackle-pathfinder-image: "quay.io/konveyor/tackle-pathfinder:${{ inputs.tag != 'latest' && inputs.tag || '1.3.0-native' }}"
tackle-ui-image: "quay.io/konveyor/tackle2-ui:${{ inputs.tag }}"
tackle-addon-admin-image: "quay.io/konveyor/tackle2-addon:${{ inputs.tag }}"
tackle-addon-windup-image: "quay.io/konveyor/tackle2-addon-windup:${{ inputs.tag }}"
tackle-image-pull-policy: IfNotPresent
tackle-windup-container-memory: 0
tackle-windup-container-cpu: 0
# end DRY

- name: Expose UI service
run: |
kubectl expose deployment tackle-ui --type=NodePort --port=8080 -n konveyor-tackle --name tackle-ui-nodeport
echo "UI_URL=$(minikube service tackle-ui-nodeport -n konveyor-tackle --url)" >>$GITHUB_ENV
- name: Run login tests
uses: cypress-io/github-action@v5
with:
working-directory: tackle-ui-tests
env: user=admin,pass=password,tackleUrl=${{ env.UI_URL }}
spec: "cypress/e2e/tests/login.test.ts"

- name: Run UI tests
uses: cypress-io/github-action@v5
with:
working-directory: tackle-ui-tests
env: user=admin,pass=Dog8code,tackleUrl="${{ env.UI_URL }}",git_user="fakeuser",git_password="${{ secrets.GITHUB_TOKEN }}",git_key="${{ secrets.GITHUB_TOKEN }}",grepTags="@${{ matrix.tier }}"
# TODO: Support cypress-split in main tackle-ui-test project
# env: user=admin,pass=Dog8code,tackleUrl="${{ env.UI_URL }}",git_user="fakeuser",git_password="${{ secrets.GITHUB_TOKEN }}",git_key="${{ secrets.GITHUB_TOKEN }}",split="${{ strategy.job-total }}",splitIndex="${{ strategy.job-index }}"
spec: "**/*.test.ts"

- name: Upload cypress report data as artifact
uses: actions/upload-artifact@v3
if: always()
with:
# name: tackle-ui-test-reports-${{ matrix.split }}
name: tackle-ui-test-reports-${{ matrix.tier }}
path: |
tackle-ui-tests/cypress/reports
tackle-ui-tests/cypress/screenshots
27 changes: 27 additions & 0 deletions .github/workflows/nightlies.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Run Konveyor nightly tests

on:
schedule:
- cron: "5 3 * * *"
workflow_dispatch:

jobs:
main-nightly:
uses: ./.github/workflows/global-ci.yml
with:
tag: latest
golang_tests_ref: main
ui_tests_ref: main
release-0_1-nightly:
uses: ./.github/workflows/global-ci.yml
with:
tag: release-0.1
golang_tests_ref: 95c17ea090d50c0c623aa7d43168f6ca8fe26a88
ui_tests_ref: mta_6.1.1
release-0_2-nightly:
uses: ./.github/workflows/global-ci.yml
with:
tag: release-0.2
golang_tests_ref: 95c17ea090d50c0c623aa7d43168f6ca8fe26a88
# TODO: this needs to be pinned to a release-0.2 specific branch
ui_tests_ref: main

0 comments on commit d06f18a

Please sign in to comment.