Skip to content

Commit

Permalink
Merge branch 'develop' into bugfix/communication/update-posting-group…
Browse files Browse the repository at this point in the history
…-in-place
  • Loading branch information
badkeyy authored Feb 18, 2025
2 parents 88a21a6 + b16a418 commit 6c58d58
Show file tree
Hide file tree
Showing 1,002 changed files with 13,413 additions and 7,886 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ on:
- 'docs/**'
- '.github/**'
- '!.github/workflows/build.yml'
- '!.github/workflows/testserver.yml'
- '!.github/workflows/testserver-deployment.yml'
- '!.github/workflows/staging-deployment.yml'
push:
branches:
- develop
Expand All @@ -32,6 +33,7 @@ on:
- created

# Keep this filename in sync with the filename environment variable (PR_AUTO_BUILD_FILE_NAME) in the testserver-deployment.yml workflow
# and with the build_workflow_name environment variable in the staging-deployment.yml workflow

jobs:

Expand Down
251 changes: 251 additions & 0 deletions .github/workflows/staging-deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,251 @@
name: Artemis Staging Deployment

on:
workflow_dispatch:
inputs:
branch_name:
description: 'Branch to deploy'
required: true
commit_sha:
description: 'Commit SHA to deploy'
required: true
environment_name:
description: 'Environment to deploy to'
required: true
type: choice
options:
- artemis-staging-localci.artemis.cit.tum.de

concurrency: ${{ github.event.inputs.environment_name }}

env:
build_workflow_name: build.yml

jobs:
check-build-status:
runs-on: ubuntu-latest
outputs:
build_workflow_run_id: ${{ steps.set_build_workflow_id.outputs.workflow_id }}
steps:
- name: Print inputs
run: |
echo "Branch: ${{ github.event.inputs.branch_name }}"
echo "Commit SHA: ${{ github.event.inputs.commit_sha }}"
echo "Environment: ${{ github.event.inputs.environment_name }}"
- name: Fetch workflow runs by branch and commit
id: get_workflow_run
uses: octokit/[email protected]
with:
route: GET /repos/${{ github.repository }}/actions/workflows/${{ env.build_workflow_name }}/runs?branch=${{ github.event.inputs.branch_name }}&head_sha=${{ github.event.inputs.commit_sha }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Extract workflow ID
id: set_build_workflow_id
run: |
WORKFLOW_DATA='${{ steps.get_workflow_run.outputs.data }}'
WORKFLOW_ID=$(echo "$WORKFLOW_DATA" | jq -r '
.workflow_runs[0].id // empty
')
if [ -z "$WORKFLOW_ID" ]; then
echo "::error::No build found for commit ${{ github.event.inputs.commit_sha }} on branch ${{ github.event.inputs.branch_name }}"
exit 1
fi
echo "Found build workflow ID: $WORKFLOW_ID for commit ${{ github.event.inputs.commit_sha }} on branch ${{ github.event.inputs.branch_name }}"
echo "workflow_id=$WORKFLOW_ID" >> $GITHUB_OUTPUT
- name: Check for war artifact
id: verify_artifact
uses: octokit/[email protected]
with:
route: GET /repos/${{ github.repository }}/actions/runs/${{ steps.set_build_workflow_id.outputs.workflow_id }}/artifacts?name=Artemis.war
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Verify artifact exists
id: check_result
run: |
TOTAL_COUNT=$(echo '${{ steps.verify_artifact.outputs.data }}' | jq -r '.total_count')
if [ "$TOTAL_COUNT" -gt 0 ]; then
echo "Found Artemis.war artifact in build for commit ${{ github.event.inputs.commit_sha }}"
else
echo "::error::No Artemis.war artifact found in build for commit ${{ github.event.inputs.commit_sha }}!"
exit 1
fi
deploy:
needs: check-build-status
runs-on: [self-hosted, ase-large-ubuntu]
environment:
name: ${{ github.event.inputs.environment_name }}
url: ${{ vars.DEPLOYMENT_URL }}
env:
DEPLOYMENT_HOSTS_PRIMARY: ${{ vars.DEPLOYMENT_HOSTS_PRIMARY }}
DEPLOYMENT_HOSTS_SECONDARY: ${{ vars.DEPLOYMENT_HOSTS_SECONDARY }}
DEPLOYMENT_USER: ${{ vars.DEPLOYMENT_USER }}
DEPLOYMENT_FOLDER: ${{ vars.DEPLOYMENT_FOLDER }}
HEALTH_CHECK_URL: "${{ vars.DEPLOYMENT_URL }}/management/health"
WORKFLOW_RUN_ID: ${{ needs.check-build-status.outputs.build_workflow_run_id }}

steps:
- name: Clean workspace
run: |
echo "[INFO] Cleaning workspace..."
rm -rf artifacts/
rm -rf ./*
mkdir -p artifacts
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: Artemis.war
path: artifacts
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ env.WORKFLOW_RUN_ID }}

- name: Setup SSH and Known Hosts
env:
DEPLOYMENT_SSH_KEY: ${{ secrets.DEPLOYMENT_SSH_KEY }}
DEPLOYMENT_HOST_PUBLIC_KEYS: ${{ vars.DEPLOYMENT_HOST_PUBLIC_KEYS }}
run: |
mkdir -p ~/.ssh
chmod 700 ~/.ssh
# Write private key
echo "$DEPLOYMENT_SSH_KEY" | sed 's/\\n/\n/g' > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
# Write known hosts
echo "$DEPLOYMENT_HOST_PUBLIC_KEYS" > ~/.ssh/known_hosts
chmod 644 ~/.ssh/known_hosts
- name: Phase 1 - Stop Secondary Nodes
run: |
HOSTS_SPACE_SEPARATED=$(echo "$DEPLOYMENT_HOSTS_SECONDARY" | tr -d '\r' | tr '\n' ' ' | awk '{$1=$1};1')
echo "Debug: Hosts list: $HOSTS_SPACE_SEPARATED"
for node in $HOSTS_SPACE_SEPARATED
do
SSH="ssh -i ~/.ssh/id_rsa -l $DEPLOYMENT_USER $node"
echo "[INFO] Stop artemis.service on ${node} ..."
$SSH sudo systemctl stop artemis
done
- name: Phase 1 - Deploy to Primary Node
run: |
echo "[INFO] Deploy on $DEPLOYMENT_HOSTS_PRIMARY ..."
SSH="ssh -o LogLevel=ERROR -i ~/.ssh/id_rsa -l $DEPLOYMENT_USER $DEPLOYMENT_HOSTS_PRIMARY"
# Store the war file name
WAR_FILE=$(ls -1 artifacts/*.war | head -n 1)
# Check if artifacts directory contains the WAR file
echo "[INFO] Checking local artifacts..."
ls -la artifacts/
if [ ! -f "$WAR_FILE" ]; then
echo "Error: No WAR file found in artifacts directory"
exit 1
fi
# Check remote directory exists and is writable
echo "[INFO] Checking remote directory..."
$SSH "if [ ! -d /opt/artemis ]; then echo 'Error: /opt/artemis directory does not exist'; exit 1; fi"
$SSH "if [ ! -w /opt/artemis ]; then echo 'Error: /opt/artemis directory is not writable'; exit 1; fi"
# Remove old backup if exists
echo "[INFO] Remove old artemis.war ..."
$SSH "rm -f /opt/artemis/artemis.war.old"
# Copy new artemis.war to node
echo "[INFO] Copy new artemis.war ..."
scp -v -i ~/.ssh/id_rsa "$WAR_FILE" $DEPLOYMENT_USER@$DEPLOYMENT_HOSTS_PRIMARY:/opt/artemis/artemis.war.new
if [ $? -ne 0 ]; then
echo "Error: Failed to copy WAR file"
exit 1
fi
# Verify the file was copied successfully
echo "[INFO] Verify new WAR file..."
$SSH '
if [ ! -f /opt/artemis/artemis.war.new ]; then
echo "Error: No WAR file found at /opt/artemis/artemis.war.new"
exit 1
fi
'
# Stop Artemis-Service on node
echo "[INFO] Stop artemis.service ..."
$SSH sudo systemctl stop artemis
# Replace old artemis.war
echo "[INFO] Rename old artemis.war ..."
$SSH mv /opt/artemis/artemis.war /opt/artemis/artemis.war.old || true
echo "[INFO] Rename new artemis.war ..."
$SSH mv /opt/artemis/artemis.war.new /opt/artemis/artemis.war
# Start Artemis-Service on node
echo "[INFO] Start artemis.service ..."
$SSH sudo systemctl start artemis
- name: Verify Primary Node Deployment
id: verify_deployment
timeout-minutes: 10
run: |
while true; do
echo "Performing health check..."
RESPONSE=$(curl -s -f $HEALTH_CHECK_URL || echo '{"status":"DOWN"}')
STATUS=$(echo $RESPONSE | grep -o '"status":"[^"]*"' | cut -d'"' -f4)
if [ "$STATUS" = "UP" ]; then
echo "Health check passed! Application is UP"
exit 0
else
echo "Health check failed. Status: $STATUS"
echo "Waiting 10 seconds before next attempt..."
sleep 10
fi
done
- name: Phase 2 - Deploy to Secondary Nodes
run: |
HOSTS_SPACE_SEPARATED=$(echo "$DEPLOYMENT_HOSTS_SECONDARY" | tr -d '\r' | tr '\n' ' ' | awk '{$1=$1};1')
WAR_FILE=$(ls -1 artifacts/*.war | head -n 1)
echo "Debug: Hosts list: $HOSTS_SPACE_SEPARATED"
for node in $HOSTS_SPACE_SEPARATED
do
echo "##################################################################################################"
echo "[INFO] Deploy on $node ..."
echo "##################################################################################################"
# Build SSH-command
SSH="ssh -o LogLevel=ERROR -i ~/.ssh/id_rsa -l $DEPLOYMENT_USER $node"
# Remove old artemis.war
echo "[INFO] Remove old artemis.war ..."
$SSH "rm -f /opt/artemis/artemis.war.old"
# Copy new artemis.war to node
echo "[INFO] Copy new artemis.war ..."
scp -i ~/.ssh/id_rsa "$WAR_FILE" "$DEPLOYMENT_USER@$node:/opt/artemis/artemis.war.new"
# Stop Artemis-Service on node
echo "[INFO] Stop artemis.service ..."
$SSH "sudo systemctl stop artemis"
# Replace old artemis.war
echo "[INFO] Rename old artemis.war ..."
$SSH "mv /opt/artemis/artemis.war /opt/artemis/artemis.war.old || true"
echo "[INFO] Rename new artemis.war ..."
$SSH "mv /opt/artemis/artemis.war.new /opt/artemis/artemis.war"
# Start Artemis-Service on node
echo "[INFO] Start artemis.service ..."
$SSH "sudo systemctl start artemis"
done
2 changes: 1 addition & 1 deletion .github/workflows/test-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
# Run artemis server in a detached mode, and store the pid in variable steps.run-artemis.outputs.pid
- name: Run Artemis Server
id: run-artemis
run: ./main-repo/gradlew bootRun --args='--spring.profiles.active=dev,artemis,scheduling --artemis.user-management.use-external=false --artemis.user-management.internal-admin.username=artemis_admin --artemis.user-management.internal-admin.password=artemis_admin --artemis.user-management.registration.enabled=true --artemis.user-management.registration.allowed-email-pattern=.*' & echo "pid=$!" >> "$GITHUB_OUTPUT"
run: ./main-repo/gradlew bootRun --args='--spring.profiles.active=dev,artemis,scheduling,atlas --artemis.user-management.use-external=false --artemis.user-management.internal-admin.username=artemis_admin --artemis.user-management.internal-admin.password=artemis_admin --artemis.user-management.registration.enabled=true --artemis.user-management.registration.allowed-email-pattern=.*' & echo "pid=$!" >> "$GITHUB_OUTPUT"

# For debug purposes or if anything goes wrong, and we have to manually kill the process on the VM
- name: Print Pid
Expand Down
49 changes: 31 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ env:
CI: true
node: 22
java: 21
# Run all tests for non-draft pull-requests or the default branch. Otherwise, only module-affected tests are run.
RUN_ALL_TESTS: ${{ (github.event_name == 'pull_request' && github.event.pull_request.draft == false) || github.event.repository.default_branch == github.ref_name }}

jobs:

Expand All @@ -59,41 +61,52 @@ jobs:
17
${{ env.java }}
cache: 'gradle'
- name: Java Tests
- name: Java Tests (module-affected)
# Not a non-draft pull-request and not the default branch
if: ${{ !env.RUN_ALL_TESTS }}
run: |
set -o pipefail
DEFAULT_BRANCH="${{ github.event.repository.default_branch }}"
CURRENT_BRANCH="${{ github.ref_name }}"
if [[ "$DEFAULT_BRANCH" != "$CURRENT_BRANCH" ]]; then
# Explicitly fetch as the clone action only clones the current branch
git fetch origin "$DEFAULT_BRANCH"
# Explicitly fetch as the clone action only clones the current branch
git fetch origin "$DEFAULT_BRANCH"
chmod +x ./supporting_scripts/get_changed_modules.sh
CHANGED_MODULES=$(./supporting_scripts/get_changed_modules.sh "origin/$DEFAULT_BRANCH")
chmod +x ./supporting_scripts/get_changed_modules.sh
CHANGED_MODULES=$(./supporting_scripts/get_changed_modules.sh "origin/$DEFAULT_BRANCH")
# Restrict executed tests to changed modules if there is diff between this and the base branch
if [ -n "${CHANGED_MODULES}" ]; then
IFS=,
TEST_MODULE_TAGS=$(echo "-DincludeModules=${CHANGED_MODULES[*]}")
# Restrict executed tests to changed modules if there is diff between this and the base branch
if [ -n "${CHANGED_MODULES}" ]; then
IFS=,
TEST_MODULE_TAGS=$(echo "-DincludeModules=${CHANGED_MODULES[*]}")
echo "Executing tests for modules: $CHANGED_MODULES"
./gradlew --console=plain test jacocoTestReport -x webapp jacocoTestCoverageVerification "$TEST_MODULE_TAGS" | tee tests.log
exit 0
fi
echo "Executing tests for modules: $CHANGED_MODULES"
./gradlew --console=plain test jacocoTestReport -x webapp jacocoTestCoverageVerification "$TEST_MODULE_TAGS" | tee tests.log
exit 0
fi
echo "Executing all tests"
./gradlew --console=plain test jacocoTestReport -x webapp jacocoTestCoverageVerification | tee tests.log
- name: Java Tests (All)
# Non-draft pull-request or default branch
if: ${{ env.RUN_ALL_TESTS }}
run: |
set -o pipefail
./gradlew --console=plain test jacocoTestReport -x webapp jacocoTestCoverageVerification | tee tests.log
- name: Upload JUnit Test Results
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: JUnit Test Results
path: build/test-results/test/*.xml
- name: Print failed tests
if: failure()
run: grep "Test >.* FAILED\$" tests.log || echo "No failed tests."
- name: "Codacy: Report coverage"
uses: codacy/codacy-coverage-reporter-action@master
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: build/reports/jacoco/test/jacocoTestReport.xml
coverage-reports: build/reports/jacoco/aggregated/jacocoTestReport.xml
if: (github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name) && (success() || failure()) && github.event.pull_request.user.login != 'dependabot[bot]'
- name: Annotate Server Test Results
uses: ashley-taylor/junit-report-annotations-action@f9c1a5cbe28479439f82b80a5402a6d3aa1990ac
Expand All @@ -117,9 +130,9 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: Coverage Report Server Tests
path: build/reports/jacoco/test/html
path: build/reports/jacoco/aggregated/html
- name: Append Per-Module Coverage to Job Summary
if: success()
if: success() || failure()
run: |
AGGREGATED_REPORT_FILE=./module_coverage_report.md
python3 ./supporting_scripts/code-coverage/per_module_cov_report/parse_module_coverage.py build/reports/jacoco $AGGREGATED_REPORT_FILE
Expand Down
8 changes: 4 additions & 4 deletions .idea/runConfigurations/Artemis_JavaScript_Debug.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/runConfigurations/Artemis__Server_.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6c58d58

Please sign in to comment.