Skip to content

Commit

Permalink
ci: move jenkins operations to GH
Browse files Browse the repository at this point in the history
  • Loading branch information
moabu committed Nov 7, 2024
1 parent 26001ea commit c60537a
Show file tree
Hide file tree
Showing 32 changed files with 474 additions and 114 deletions.
9 changes: 9 additions & 0 deletions .github/maven-settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<settings>
<servers>
<server>
<id>github</id>
<username>${env.GITHUB_ACTOR}</username>
<password>${env.JANS_TOKEN}</password>
</server>
</servers>
</settings>
100 changes: 0 additions & 100 deletions .github/workflows/build-wars.yml

This file was deleted.

179 changes: 179 additions & 0 deletions .github/workflows/full-rebuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
name: Jans Full Build

on:
push:
branches:
- main
schedule:
- cron: '0 8 * * *'
pull_request:
branches:
- main
workflow_dispatch:


jobs:
full-build-with-disabled-tests:
runs-on: ubuntu-20.04
permissions:
contents: read
packages: write
env:
VERSION_NAME: main
MAVEN_SKIP_TESTS: true
PROFILE_NAME: "default"

strategy:
max-parallel: 1
matrix:
service:
- "jans-bom"
- "jans-orm"
- "jans-core"
- "jans-lock/lock-server"
- "agama"
- "jans-auth-server"
- "jans-link"
- "jans-fido2"
- "jans-scim"
- "jans-keycloak-link"
- "jans-config-api"
- "jans-keycloak-integration"
- "jans-casa"

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch }}

- name: Set up Java 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'

- name: Set up Maven
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'
cache: 'maven'

- name: Build ${{ matrix.service }}
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
mvn -f ${{ matrix.service }}/pom.xml -Dcfg=${{ env.PROFILE_NAME }} -Dmaven.test.skip=${{ env.MAVEN_SKIP_TESTS }} clean install -Drevision=${{ github.head_ref }}-SNAPSHOT
else
mvn -f ${{ matrix.service }}/pom.xml -Dcfg=${{ env.PROFILE_NAME }} -Dmaven.test.skip=${{ env.MAVEN_SKIP_TESTS }} clean install
fi
- name: Publish to GitHub Packages
run: mvn -B deploy -Dmaven.test.skip=${{ env.MAVEN_SKIP_TESTS }} -Dcfg=${{ env.PROFILE_NAME }}
working-directory: ${{ matrix.service }}
env:
GITHUB_TOKEN: ${{ secrets.JANS_TOKEN }}

- name: Archive results
if: always()
uses: actions/upload-artifact@v4
with:
name: build-results
path: ${{ matrix.service }}/target

- name: Send notification on failure
if: failure()
run: echo "Build failed"

cleanup:
if: github.event_name == 'push' && github.event.ref == 'refs/heads/main'
runs-on: ubuntu-20.04
steps:

- name: Clean up PR assets
run: |
# List all SNAPSHOT versions
versions=$(curl -s -H "Authorization: token ${{ secrets.JANS_TOKEN }}" "https://maven.pkg.github.com/JanssenProject/jans/maven-metadata.xml" | grep -oP '(?<=<version>)[^<]+')
for version in $versions; do
if [[ $version == *-SNAPSHOT ]]; then
# Delete the version from GitHub Packages
curl -X DELETE -H "Authorization: token ${{ secrets.JANS_TOKEN }}" "https://maven.pkg.github.com/JanssenProject/jans/io/jans/${{ matrix.service }}/$version"
fi
done
run-tests:
permissions: write-all
runs-on: ubuntu-20.04
env:
MAVEN_SKIP_TESTS: false
CONTAINER_NAME_SPANNER: ubuntu20-spanner
CONTAINER_NAME_CB: ubuntu20-couchbase
CONTAINER_NAME_LDAP: ubuntu20-ldap
CONTAINER_NAME_MYSQL: ubuntu20-mysql
CONTAINER_NAME_POSTGRESQL: ubuntu20-postgresql
DEVELOPMENT_BUILD: true
SKIP_FINDBUGS: true
DEPENDENCY_CHECK: true
VERSION_NAME: main
PROFILE_NAME: default
strategy:
max-parallel: 5
matrix:
persistence:
- "MYSQL"
- "PGSQL"
fail-fast: false
steps:

- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch }}

- name: Set up Java 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'

- name: Set up Maven
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'
cache: 'maven'

- name: Run Jans Monolith
env:
JANS_FQDN: demoexample.jans.io
EXT_IP: $(ifconfig eth0 | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1')
JANS_BUILD_COMMIT: main
run: |
export ip=$(ifconfig eth0 | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1')
sudo chmod a+x automation/startjanssenmonolithdemo.sh
sudo RUN_TESTS=true bash ./automation/startjanssenmonolithdemo.sh "demoexample.jans.io" "${{ matrix.persistence }}" "$ip" "${{ github.sha }}"
- name: List Reports
run: |
ls /tmp/reports/
- name: Upload Test Results
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.persistence }}-test-results
path: /tmp/reports

- name: Publish Test Report ${{ matrix.persistence }}
uses: starburstdata/action-testng-report@v1
with:
report_paths: /tmp/reports/${{ matrix.persistence }}*.xml
github_token: ${{ github.token }}
fail_if_empty: false

# - name: Publish Test Report Surefire
# uses: scacap/action-surefire-report@v1
# if: success() || failure()
# with:
# github_token: ${{ github.token }}
# report_paths: /tmp/reports/**.xml
5 changes: 5 additions & 0 deletions agama/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
</properties>

<repositories>
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/JanssenProject/jans</url>
</repository>
<repository>
<id>jans</id>
<name>Janssen project repository</name>
Expand Down
24 changes: 22 additions & 2 deletions automation/startjanssenmonolithdemo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ WORKING_DIRECTORY=$PWD
# note that as we're pulling from a monorepo (with multiple project in it)
# we are using partial-clone and sparse-checkout to get the docker-jans-monolith code
rm -rf /tmp/jans || echo "/tmp/jans doesn't exist"
git clone --filter blob:none --no-checkout https://github.com/janssenproject/jans /tmp/jans \
git clone --filter blob:none --no-checkout https://github.com/JanssenProject/jans /tmp/jans \
&& cd /tmp/jans \
&& git sparse-checkout init --cone \
&& git checkout "$JANS_BUILD_COMMIT" \
Expand Down Expand Up @@ -132,15 +132,35 @@ while [ $SECONDS -lt $end ]; do
sleep 10
done
echo -e "Running build.. \n"
docker exec -w /tmp/jans/jans-orm docker-jans-monolith-jans-1 mvn -Dcfg="$JANS_FQDN" -Dmaven.test.skip=true clean compile install
docker exec -w /tmp/jans/jans-auth-server docker-jans-monolith-jans-1 mvn -Dcfg="$JANS_FQDN" -Dmaven.test.skip=true -fae clean compile install
docker exec -w /tmp/jans/jans-auth-server/agama docker-jans-monolith-jans-1 mvn -Dcfg="$JANS_FQDN" -Dmaven.test.skip=true -fae clean compile install
docker exec -w /tmp/jans/jans-scim docker-jans-monolith-jans-1 mvn -Dcfg="$JANS_FQDN" -Dmaven.test.skip=true clean compile install site
docker exec -w /tmp/jans/jans-config-api docker-jans-monolith-jans-1 mvn -Dcfg="$JANS_FQDN" -Dmaven.test.skip=true clean compile install
docker exec -w /tmp/jans/jans-fido2 docker-jans-monolith-jans-1 mvn -Dcfg="$JANS_FQDN" -Dmaven.test.skip=true clean compile install
echo -e "Running tests.. \n"
docker exec -w /tmp/jans/jans-orm docker-jans-monolith-jans-1 mvn -Dcfg="$JANS_FQDN" -Dmaven.test.skip=false test
docker exec -w /tmp/jans/jans-auth-server docker-jans-monolith-jans-1 mvn -Dcfg="$JANS_FQDN" -Dmaven.test.skip=false test
docker exec -w /tmp/jans/jans-auth-server/agama docker-jans-monolith-jans-1 mvn -Dcfg="$JANS_FQDN" -Dmaven.test.skip=false test
docker exec -w /tmp/jans/jans-scim docker-jans-monolith-jans-1 mvn -Dcfg="$JANS_FQDN" -Dmaven.test.skip=false test
docker exec -w /tmp/jans/jans-config-api docker-jans-monolith-jans-1 mvn -Dcfg="$JANS_FQDN" -Dmaven.test.skip=false -DfailIfNoTests=false -Dtest=io.jans.configapi.JenkinsTestRunner test
docker exec -w /tmp/jans/jans-fido2 docker-jans-monolith-jans-1 mvn -Dcfg="$JANS_FQDN" -Dmaven.test.skip=false test
echo -e "copying reports.. \n"
docker cp docker-jans-monolith-jans-1:/tmp/jans/jans-auth-server/client/target/surefire-reports/testng-results.xml /tmp/reports/$JANS_PERSISTENCE-jans-auth-client-testng-results.xml
docker cp docker-jans-monolith-jans-1:/tmp/jans/jans-auth-server/agama/model/target/surefire-reports/testng-results.xml /tmp/reports/$JANS_PERSISTENCE-jans-auth-agama-model-testng-results.xml
docker cp docker-jans-monolith-jans-1:/tmp/jans/jans-auth-server/test-model/target/surefire-reports/testng-results.xml /tmp/reports/$JANS_PERSISTENCE-jans-auth-test-model-testng-results.xml
docker cp docker-jans-monolith-jans-1:/tmp/jans/jans-auth-server/model/target/surefire-reports/testng-results.xml /tmp/reports/$JANS_PERSISTENCE-jans-auth-model-testng-results.xml
docker cp docker-jans-monolith-jans-1:/tmp/jans/jans-orm/couchbase/target/surefire-reports/testng-results.xml /tmp/reports/$JANS_PERSISTENCE-jans-orm-couchbase-testng-results.xml
docker cp docker-jans-monolith-jans-1:/tmp/jans/jans-orm/spanner-sample/target/surefire-reports/testng-results.xml /tmp/reports/$JANS_PERSISTENCE-jans-orm-spanner-sample-testng-results.xml
docker cp docker-jans-monolith-jans-1:/tmp/jans/jans-orm/couchbase-sample/target/surefire-reports/testng-results.xml /tmp/reports/$JANS_PERSISTENCE-jans-orm-couchbase-sample-testng-results.xml
docker cp docker-jans-monolith-jans-1:/tmp/jans/jans-orm/sql-sample/target/surefire-reports/testng-results.xml /tmp/reports/$JANS_PERSISTENCE-jans-orm-sql-sample-testng-results.xml
docker cp docker-jans-monolith-jans-1:/tmp/jans/jans-orm/sql/target/surefire-reports/testng-results.xml /tmp/reports/$JANS_PERSISTENCE-jans-orm-sql-testng-results.xml
docker cp docker-jans-monolith-jans-1:/tmp/jans/jans-orm/spanner/target/surefire-reports/testng-results.xml /tmp/reports/$JANS_PERSISTENCE-jans-orm-spanner-testng-results.xml
docker cp docker-jans-monolith-jans-1:/tmp/jans/jans-orm/util/target/surefire-reports/testng-results.xml /tmp/reports/$JANS_PERSISTENCE-jans-orm-util-testng-results.xml
docker cp docker-jans-monolith-jans-1:/tmp/jans/jans-orm/model/target/surefire-reports/testng-results.xml /tmp/reports/$JANS_PERSISTENCE-jans-orm-model-testng-results.xml
docker cp docker-jans-monolith-jans-1:/tmp/jans/jans-orm/filter/target/surefire-reports/testng-results.xml /tmp/reports/$JANS_PERSISTENCE-jans-orm-filter-testng-results.xml
docker cp docker-jans-monolith-jans-1:/tmp/jans/jans-scim/client/target/surefire-reports/testng-results.xml /tmp/reports/$JANS_PERSISTENCE-jans-scim-client-testng-results.xml
docker cp docker-jans-monolith-jans-1:/tmp/jans/jans-config-api/server/target/surefire-reports/results-json.txt /tmp/reports/$JANS_PERSISTENCE-jans-config-api-server-testng-results.xml
EOF
if [[ "$RUN_TESTS" == "true" ]]; then
sudo bash testendpoints.sh
Expand Down
Loading

0 comments on commit c60537a

Please sign in to comment.