CI: Split up build flow to inject interop tests #601
Workflow file for this run
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
# Version 2023-03-05 | |
name: Java CI | |
on: [push, pull_request] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
java: [ "11" ] | |
steps: | |
# Checkout Repo | |
- uses: actions/checkout@v3 | |
# Create a variable with this plugin's name | |
- id: get-id | |
name: Compute needed variables | |
run: | | |
set -x | |
id=$(echo ${{ github.repository }} | cut -d- -f2) | |
echo "id=$id" >> $GITHUB_OUTPUT | |
echo "id is '$id'" | |
tag=$(echo ${{ github.ref }} | cut -d '/' -f3) | |
echo "tag=$tag" >> $GITHUB_OUTPUT | |
echo "tag is '$tag'" | |
version=$(echo ${{ github.ref }} | cut -d '/' -f3 | cut -c 2-) | |
echo "version=$version" >> $GITHUB_OUTPUT | |
echo "version is '$version'" | |
rel_id=$(curl -sL --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' https://api.github.com/repos/${{github.repository}}/releases | jq -r --arg TAG "$tag" '.[] | select(.tag_name==$TAG) | .id') | |
echo "rel_id=$rel_id" >> $GITHUB_OUTPUT | |
echo "rel_id is '$rel_id'" | |
- name: Setup JDK ${{ matrix.java }} | |
uses: actions/setup-java@v3 | |
with: | |
java-version: ${{ matrix.java }} | |
distribution: temurin | |
- name: Cache Maven repository | |
uses: actions/cache@v3 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-java${{ matrix.java }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-java${{ matrix.java }}-maven- | |
${{ runner.os }}- | |
- name: Igniterealtime CI Tooling | |
run: | | |
git clone --depth 1 https://github.com/igniterealtime/ci-tooling.git target/ci-tooling | |
cp target/ci-tooling/maven-settings-for-openfire-plugins.xml $HOME/.m2/settings.xml | |
- name: Build with Maven | |
run: mvn -B package | |
- name: Stash the built artifacts | |
uses: actions/upload-artifact@v4 | |
if: ${{ matrix.java == 11}} | |
with: | |
name: ${{ steps.get-id.outputs.id }} | |
path: target/${{ steps.get-id.outputs.id }}-openfire-plugin-assembly.jar | |
retention-days: 3 | |
test: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Download the built plugin | |
uses: actions/download-artifact@v4 | |
with: | |
name: monitoring | |
path: . | |
- name: Rename plugin | |
run: | | |
mv monitoring-openfire-plugin-assembly.jar monitoring.jar | |
- name: Run Openfire | |
uses: igniterealtime/launch-openfire-action@v1.1.2 | |
with: | |
version: 4.9.0 | |
plugin: ./monitoring.jar | |
- name: Run XMPP interop tests | |
uses: XMPP-Interop-Testing/xmpp-interop-tests-action@main | |
with: | |
domain: 'example.org' | |
adminAccountUsername: 'admin' | |
adminAccountPassword: 'admin' | |
enabledSpecifications: 'XEP-0136, XEP-0313' | |
deploy: | |
runs-on: ubuntu-latest | |
needs: test | |
steps: | |
- name: Download the built plugin | |
uses: actions/download-artifact@v4 | |
with: | |
name: monitoring | |
path: . | |
- name: Igniterealtime CI Tooling | |
run: | | |
git clone --depth 1 https://github.com/igniterealtime/ci-tooling.git target/ci-tooling | |
cp target/ci-tooling/maven-settings-for-openfire-plugins.xml $HOME/.m2/settings.xml | |
- name: Conditionally Deploy to Igniterealtime Archiva | |
id: deploy | |
if: ${{ contains(github.repository, 'igniterealtime/') && ( ( github.event_name == 'push' && github.ref == 'refs/heads/main' ) || contains(github.ref, 'refs/tags/') ) && matrix.java == '11' }} | |
run: mvn -B deploy -Dmaven.resolver.transport=wagon --settings target/ci-tooling/maven-settings-for-openfire-plugins.xml | |
env: | |
CI_DEPLOY_USERNAME: ${{ secrets.IGNITE_REALTIME_MAVEN_USERNAME }} | |
CI_DEPLOY_PASSWORD: ${{ secrets.IGNITE_REALTIME_MAVEN_PASSWORD }} | |
- name: Conditionally Push Artifact to Github Release | |
uses: actions/upload-release-asset@v1 | |
if: ${{ contains(github.repository, 'igniterealtime/') && github.event_name == 'push' && contains(github.ref, 'refs/tags/') && matrix.java == '11' }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: https://uploads.github.com/repos/${{ github.repository }}/releases/${{ steps.get-id.outputs.rel_id }}/assets?name=${{ steps.get-id.outputs.id }}.jar | |
asset_path: target/${{ steps.get-id.outputs.id }}-openfire-plugin-assembly.jar | |
asset_name: ${{ steps.get-id.outputs.id }}.jar | |
asset_content_type: application/java-archive |