forked from cryostatio/cryostat-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from mwangggg/221-cryostat-IT
fix(ci): cryostat IT
- Loading branch information
Showing
2 changed files
with
171 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,141 @@ | ||
name: CI build | ||
|
||
concurrency: | ||
group: ci-${{ github.run_id }} | ||
cancel-in-progress: true | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- v[0-9]+ | ||
- v[0-9]+.[0-9]+ | ||
- cryostat-v[0-9]+.[0-9]+ | ||
pull_request: | ||
pull_request_target: | ||
types: | ||
- opened | ||
- reopened | ||
- synchronize | ||
- labeled | ||
- unlabeled | ||
branches: | ||
- main | ||
- v[0-9]+ | ||
- v[0-9]+.[0-9]+ | ||
- cryostat-v[0-9]+.[0-9]+ | ||
|
||
jobs: | ||
build: | ||
build-core: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
test_version: ${{ steps.get_core_version.outputs.test_version }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- id: get_core_version | ||
run: | | ||
echo "test_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_OUTPUT | ||
echo "name=$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)" >> $GITHUB_OUTPUT | ||
- uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
cache: 'maven' | ||
- run: mvn -B -U clean install | ||
|
||
build-cryostat: | ||
needs: [build-core] | ||
strategy: | ||
matrix: | ||
arch: [amd64, arm64] | ||
uses: ./.github/workflows/cryostat-build.yml | ||
with: | ||
build-arch: ${{ matrix.arch }} | ||
test-version: ${{ needs.build-core.outputs.test_version }} | ||
|
||
push-to-ghcr: | ||
runs-on: ubuntu-latest | ||
needs: [build-cryostat] | ||
strategy: | ||
matrix: | ||
arch: [amd64, arm64] | ||
outputs: | ||
amd64_image: ${{ steps.amd64_image.outputs.image }} | ||
arm64_image: ${{ steps.arm64_image.outputs.image }} | ||
permissions: | ||
packages: write | ||
steps: | ||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: cryostat-${{ matrix.arch }} | ||
- name: Load cryostat image | ||
run: podman load -i cryostat-${{ matrix.arch }}.tar | ||
- name: Tag cryostat image | ||
run: podman tag cryostat ghcr.io/${{ github.repository_owner }}/cryostat-core:pr-${{ github.event.number }}-${{ github.event.pull_request.head.sha }}-linux-${{ matrix.arch }} | ||
- name: Push PR test image to ghcr.io | ||
id: push-to-ghcr | ||
uses: redhat-actions/push-to-registry@v2 | ||
with: | ||
image: cryostat-core | ||
tags: pr-${{ github.event.number }}-${{ github.event.pull_request.head.sha }}-linux-${{ matrix.arch }} | ||
registry: ghcr.io/${{ github.repository_owner }} | ||
username: ${{ github.event.pull_request.user.login }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Store images as output amd64 | ||
if: ${{ matrix.arch == 'amd64' }} | ||
id: amd64_image | ||
run: z "image=${{ steps.push-to-ghcr.outputs.registry-path }}" >> "$GITHUB_OUTPUT" | ||
- name: Store images as output | ||
if: ${{ matrix.arch == 'arm64' }} | ||
id: arm64_image | ||
run: echo "image=${{ steps.push-to-ghcr.outputs.registry-path }}" >> "$GITHUB_OUTPUT" | ||
|
||
cryostat-test: | ||
runs-on: ubuntu-latest | ||
needs: [push-to-ghcr] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-java@v2 | ||
- uses: actions/checkout@v4 | ||
with: | ||
java-version: '11' | ||
distribution: 'temurin' | ||
- uses: skjolber/maven-cache-github-action@v1 | ||
repository: ${{ github.repository_owner }} | ||
ref: main | ||
submodules: true | ||
fetch-depth: 0 | ||
- uses: actions/setup-java@v3 | ||
with: | ||
step: restore | ||
- run: mvn -B -U clean verify | ||
- uses: skjolber/maven-cache-github-action@v1 | ||
java-version: '17' | ||
distribution: 'temurin' | ||
cache: maven | ||
- name: Pull cryostat image | ||
run: podman pull ghcr.io/${{ github.repository_owner }}/cryostat-core:pr-${{ github.event.number }}-${{ github.event.pull_request.head.sha }}-linux-${{ matrix.arch }} | ||
- name: Run integration tests | ||
run: POD_NAME=cryostat-itests CONTAINER_NAME=cryostat-itest ITEST_IMG_VERSION=latest bash repeated-integration-tests.bash | ||
- name: Print itest logs | ||
if: failure() | ||
run: ls -1dt target/cryostat-itest-*.log | head -n1 | xargs cat | ||
- name: Print itest container logs | ||
if: failure() | ||
run: ls -1dt target/cryostat-*.server.log | head -n1 | xargs cat | ||
|
||
comment-image: | ||
runs-on: ubuntu-latest | ||
needs: [push-to-ghcr] | ||
env: | ||
amd64_image: ${{ needs.push-to-ghcr.outputs.amd64_image }} | ||
arm64_image: ${{ needs.push-to-ghcr.outputs.arm64_image }} | ||
permissions: | ||
pull-requests: write | ||
steps: | ||
- name: Create markdown table | ||
id: md-table | ||
uses: petems/[email protected] | ||
with: | ||
csvinput: | | ||
ARCH, IMAGE | ||
amd64, ${{ env.amd64_image }} | ||
arm64, ${{ env.arm64_image }} | ||
- uses: thollander/actions-comment-pull-request@v2 | ||
with: | ||
step: save | ||
message: |- | ||
${{ steps.md-table.outputs.markdown-table }} | ||
To run smoketest: | ||
``` | ||
# amd64 | ||
CRYOSTAT_IMAGE=${{ env.amd64_image }} sh smoketest.sh | ||
# or arm64 | ||
CRYOSTAT_IMAGE=${{ env.arm64_image }} sh smoketest.sh | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
on: | ||
workflow_call: | ||
inputs: | ||
build-arch: | ||
required: true | ||
type: string | ||
core-version: | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
build-image: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Install qemu | ||
if: ${{ inputs.build-arch != 'amd64' }} | ||
continue-on-error: true | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y qemu-user-static | ||
- uses: actions/checkout@v4 | ||
with: | ||
repository: ${{ github.repository_owner }}/cryostat | ||
ref: main | ||
submodules: true | ||
fetch-depth: 0 | ||
- uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
cache: maven | ||
- name: maven-settings | ||
uses: s4u/maven-settings-action@v2 | ||
with: | ||
servers: '[{"id": "github", "username": "dummy", "password": "${env.GITHUB_TOKEN_REF}"}]' | ||
githubServer: false | ||
- run: git submodule init | ||
- run: git submodule update | ||
- run: mvn -B -U -Dbuild.arch=${{ inputs.build-arch }} -Dio.cryostat.core.version=${{ inputs.core-version }} clean package | ||
env: | ||
GITHUB_TOKEN_REF: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Save cryostat image | ||
run: podman save -o cryostat-${{ inputs.build-arch }}.tar --format oci-archive quay.io/cryostat/cryostat | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: cryostat-${{ inputs.build-arch }} | ||
path: ${{ github.workspace }}/cryostat-${{ inputs.build-arch }}.tar |