Skip to content

Commit

Permalink
Recombine native image build and agent report workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
JohT committed Jan 29, 2022
1 parent bc4a85e commit 90c5c41
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 135 deletions.
97 changes: 0 additions & 97 deletions .github/workflows/native-image-agent.yml

This file was deleted.

113 changes: 75 additions & 38 deletions .github/workflows/native-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ on:
push:
branches:
- master
# Ignore changes in documentation and reports
# Ignore changes in documentation and native image agent results
paths-ignore:
- 'showcase-quarkus-eventsourcing/native-image-agent-results/**'
- '**/*.md'
- '**/*.txt'
pull_request:
branches:
- master
# Ignore changes in documentation and reports
# Ignore changes in documentation and native image agent results
paths-ignore:
- 'showcase-quarkus-eventsourcing/native-image-agent-results/**'
- '**/*.md'
Expand All @@ -28,27 +28,26 @@ jobs:
CI_COMMIT_MESSAGE: Automated native image agent results (CI)
CI_COMMIT_AUTHOR: ${{ github.event.repository.name }} Continuous Integration
GRAALVM_VERSION: 22.0.0.2
outputs:
ci-commit-message: ${{ steps.ci-commit-message-output.outputs.ci-commit-message }}
ci-commit-author: ${{ steps.ci-commit-author-output.outputs.ci-commit-author }}
is-ci-commit: ${{ steps.is-ci-commit-output.outputs.is-ci-commit }}
original-event-name: ${{ steps.original-event-name-output.outputs.original-event-name }}
graalvm_version: ${{ env.GRAALVM_VERSION }}
steps:
- uses: actions/checkout@v2
- name: Checkout git repository
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.WORKFLOW_GIT_ACCESS_TOKEN }}

# Get the message of the current commit
- name: Set environment variable "commit-message"
run: echo "commit-message=$(git log -1 --pretty=format:"%s")" >> $GITHUB_ENV
- name: Display environment variable "commit-message"
run: echo "commit-message=${{ env.commit-message }}"

# Get the author name of the current commit
- name: Set environment variable "commit-author"
run: echo "commit-author=$(git log -1 --pretty=format:'%an')" >> $GITHUB_ENV
- name: Display environment variable "commit-author"
run: echo "commit-author=${{ env.commit-author }}"

# Detect if the current commit was automatically pushed by continuous integration
# Detect if the current commit was automatically pushed by this workflow (for endless loop prevention)
- name: Set environment variable "is-ci-commit"
if: env.commit-message == env.CI_COMMIT_MESSAGE && env.commit-author == env.CI_COMMIT_AUTHOR
run: echo "is-ci-commit=true" >> $GITHUB_ENV
Expand All @@ -58,20 +57,7 @@ jobs:
if: env.is-ci-commit
run: echo "Continuous Integration Auto Commit - The following steps will be skipped"

# Set job output parameter values
- name: Set output parameter "ci-commit-message"
id: ci-commit-message-output
run: echo "::set-output name=ci-commit-message::${{ env.CI_COMMIT_MESSAGE }}"
- name: Set output parameter "ci-commit-author"
id: ci-commit-author-output
run: echo "::set-output name=ci-commit-author::${{ env.CI_COMMIT_AUTHOR }}"
- name: Set output parameter "is-ci-commit"
id: is-ci-commit-output
run: echo "::set-output name=is-ci-commit::${{ env.is-ci-commit }}"
- name: Set output parameter "original-event-name"
id: original-event-name-output
run: echo "::set-output name=original-event-name::${{ github.event_name }}"

# Cache maven repository
- uses: actions/cache@v2
if: env.is-ci-commit == false
with:
Expand All @@ -80,6 +66,7 @@ jobs:
restore-keys: |
${{ runner.os }}-maven-
# Download and prepare GraalVM Community Edition including native image tools
- name: Setup GraalVM Community Edition
if: env.is-ci-commit == false
uses: DeLaGuardo/setup-graalvm@5.0
Expand All @@ -90,22 +77,72 @@ jobs:
if: env.is-ci-commit == false
run: gu install native-image

# Build the native image of the application.
- name: Build native image with Maven
if: env.is-ci-commit == false
working-directory: showcase-quarkus-eventsourcing
run: mvn verify --activate-profiles native --file pom.xml --batch-mode

include-native-image-agent:
needs: native-image-build
#Variables are not yet supported for "uses". Workaround are hardcoded git refs. TODO: Change to main/master branch as soon as merged.
#https://stackoverflow.com/questions/69737232/github-context-variables-not-evaluating-for-reusable-workflow-reference
#uses: JohT/showcase-quarkus-eventsourcing/.github/workflows/native-image-agent.yml@${{github.event.pull_request.head.ref}}
uses: JohT/showcase-quarkus-eventsourcing/.github/workflows/native-image-agent.yml@update/graalvm-22
if: needs.native-image-build.outputs.is-ci-commit == false
with:
ci-commit-message: ${{ needs.native-image-build.outputs.ci-commit-message }}
ci-commit-author: ${{ needs.native-image-build.outputs.ci-commit-author }}
original-event-name: ${{ needs.native-image-build.outputs.original-event-name }}
graalvm-version: ${{ needs.native-image-build.outputs.graalvm-version }}
secrets:
git-push-access-token: ${{ secrets.WORKFLOW_GIT_ACCESS_TOKEN }}
# Run integration tests with activated native image agent to get trace and report files about e.g. reflection usage
- name: Run integration tests on GraalVM with activated native-image-agent for trace file generation
if: env.is-ci-commit == false
working-directory: showcase-quarkus-eventsourcing
run: mvn verify --activate-profiles native-image-agent-trace --file pom.xml --batch-mode && sleep 4
- name: Generate configuration json files out of the native-image-agent trace output
if: env.is-ci-commit == false
working-directory: showcase-quarkus-eventsourcing
run: $GRAALVM_HOME/bin/native-image-configure generate --trace-input=target/native-image-agent-trace.json --output-dir=target/native-image-agent-trace-configs --caller-filter-file=native-image-caller-filter-rules.json

# Assemble the name of the native image agent results directory based on Java, Axon, Quarkus and GraalVM version
- name: Get the axon version from the maven pom variable and set the environment variable "axon-version"
if: env.is-ci-commit == false
working-directory: showcase-quarkus-eventsourcing
run: echo "axon-version=$(mvn -q help:evaluate -Dexpression=axon.version -DforceStdout | tr . -)" >> $GITHUB_ENV
- name: Get the quarkus version from the maven pom variable and set the environment variable "quarkus-version"
if: env.is-ci-commit == false
working-directory: showcase-quarkus-eventsourcing
run: echo "quarkus-version=$(mvn -q help:evaluate -Dexpression=quarkus.platform.version -DforceStdout | tr . -)" >> $GITHUB_ENV
- name: Get the GraalVM version with "-" instead of "." delimiters
if: env.is-ci-commit == false
run: echo "graalvm-version-string=$(echo ${{ env.GRAALVM_VERSION }} | tr . -)" >> $GITHUB_ENV
- name: Assemble the name of the directory for the native image agent output files and set the environment variable "native-image-agent-results-directory"
if: env.is-ci-commit == false
run: echo "native-image-agent-results-directory=native-image-agent-results/${{ matrix.java }}-axon-${{ env.axon-version }}-quarkus-${{ env.quarkus-version }}-graalvm-${{ env.graalvm-version-string }}" >> $GITHUB_ENV

# Create the directory with the previously assembled name within "native-image-agent-results" and fill in the result files.
- name: Create the native image agent results directory
if: env.is-ci-commit == false
working-directory: showcase-quarkus-eventsourcing
run: mkdir -p ${{ env.native-image-agent-results-directory }}
- name: Copy the native image agent trace file into the native image agent results directory
if: env.is-ci-commit == false
working-directory: showcase-quarkus-eventsourcing
run: cp target/native-image-agent-trace.json ${{ env.native-image-agent-results-directory }}
- name: Copy the native image agent configuration files into the native image agent results directory
if: env.is-ci-commit == false
working-directory: showcase-quarkus-eventsourcing
run: cp target/native-image-agent-trace-configs/* ${{ env.native-image-agent-results-directory }}

# Upload the native image agent results in case they are needed for troubleshooting for a couple of days
- name: Archive native image agent results
if: env.is-ci-commit == false
uses: actions/upload-artifact@v2
with:
name: native-image-agent-results-${{ matrix.java }}
path: showcase-quarkus-eventsourcing/${{ env.native-image-agent-results-directory }}
if-no-files-found: error
retention-days: 5

# Commit and push the native image agent results
- name: Display environment variable "github.event_name"
run: echo "github.event_name=${{ github.event_name }}"
- name: Commit native image agent results
working-directory: showcase-quarkus-eventsourcing
# Don't run again on already pushed continuous integration auto commit. Only run when pushed to main branch.
if: env.is-ci-commit == false && github.event_name == 'push'
run: |
git config --global user.name '${{ env.CI_COMMIT_AUTHOR }}'
git config --global user.email 'joht@users.noreply.github.com'
git add ${{ env.native-image-agent-results-directory }}
git commit -m "${{ env.CI_COMMIT_MESSAGE }}"
git push

0 comments on commit 90c5c41

Please sign in to comment.