-
Notifications
You must be signed in to change notification settings - Fork 541
12367 GitHub actions workflow for jenkins redundancy #12368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 2 commits
c206ebf
d16c320
5925618
b0e2c76
953d70a
171112c
3e3e035
7f89dfa
e0c2b57
2515d17
588ff79
0fb13ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,332 @@ | ||
| name: Container Integration Tests Workflow | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| force_run: | ||
| description: 'Force run even if ENABLE_DOCKER_TESTS is false' | ||
| required: false | ||
| type: boolean | ||
| default: false | ||
| push: | ||
| branches: | ||
| - develop | ||
| paths-ignore: | ||
| - "doc/**" | ||
| - "**/*.md" | ||
| - "**/*.txt" | ||
| - ".github/ISSUE_TEMPLATE/**" | ||
| - ".github/*.md" | ||
|
Comment on lines
+6
to
+13
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need "push" at all? We have branch protection turned on for both "develop" and "master". |
||
| pull_request: | ||
| branches: | ||
| - develop | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add "master" here? That way the tests will run when we release, I would think, after this step: https://guides.dataverse.org/en/6.10.1/developers/making-releases.html#merge-develop-into-master-non-hotfix-only Here's an example of where we merged develop into master: |
||
| paths-ignore: | ||
| - "doc/**" | ||
| - "**/*.md" | ||
| - "**/*.txt" | ||
| - ".github/ISSUE_TEMPLATE/**" | ||
| - ".github/*.md" | ||
|
srmanda-cs marked this conversation as resolved.
|
||
|
|
||
| concurrency: | ||
| group: "container-integration-tests-group" | ||
|
srmanda-cs marked this conversation as resolved.
Outdated
|
||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| main-integration-tests-workflow: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 120 | ||
|
|
||
| defaults: | ||
| run: | ||
| shell: bash | ||
|
|
||
| permissions: | ||
|
srmanda-cs marked this conversation as resolved.
|
||
| checks: write | ||
| pull-requests: write | ||
|
|
||
| steps: | ||
|
|
||
| # --------------------------- | ||
| # CHECKOUT | ||
| # --------------------------- | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v6 | ||
|
|
||
| # --------------------------- | ||
| # VERIFY DOCKER | ||
| # --------------------------- | ||
| - name: Verify Docker | ||
| run: | | ||
| set -euo pipefail | ||
| docker version | ||
|
|
||
| # --------------------------- | ||
| # SETUP JAVA + MAVEN | ||
| # --------------------------- | ||
| - name: Setup Java | ||
| uses: actions/setup-java@v5 | ||
| with: | ||
| distribution: "temurin" | ||
| java-version: "21" | ||
| cache: "maven" | ||
|
|
||
| - name: Verify Maven | ||
| run: | | ||
| set -euo pipefail | ||
| mvn -version | ||
|
|
||
| # --------------------------- | ||
| # CLEAN PREVIOUS VOLUMES | ||
| # --------------------------- | ||
| - name: Clean docker-dev-volumes | ||
| run: | | ||
| set -euo pipefail | ||
| rm -rf docker-dev-volumes || true | ||
|
|
||
| # --------------------------- | ||
| # BUILD IMAGES (Dataverse-native) | ||
| # --------------------------- | ||
| - name: Build Dataverse containers via Maven | ||
| run: | | ||
| set -euo pipefail | ||
| # Force unit tests to run, generate coverage, and ignore failures so the build continues | ||
| mvn clean package -Pct -P all-unit-tests \ | ||
| -DskipUnitTests=false \ | ||
| -Djacoco.skip=false \ | ||
| -Dmaven.test.failure.ignore=true | ||
|
|
||
| # --------------------------- | ||
| # START CONTAINERS (BACKGROUND) | ||
| # --------------------------- | ||
| - name: Start Dataverse stack | ||
| run: | | ||
| set -euo pipefail | ||
| mvn -Pct docker:start \ | ||
| -Ddataverse.cors.origin=* \ | ||
| -Ddataverse.cors.methods=GET,POST,PUT,DELETE,OPTIONS \ | ||
| -Ddataverse.cors.headers.allow=range,content-type,x-dataverse-key,accept \ | ||
| -Ddataverse.cors.headers.expose=content-encoding,content-range,accept-ranges \ | ||
| -Ddataverse.feature.index-harvested-metadata-source=true \ | ||
| -Ddataverse.oai.server.maxidentifiers=2 \ | ||
| -Ddataverse.oai.server.maxrecords=2 \ | ||
|
|
||
| # --------------------------- | ||
| # WAIT FOR API READINESS | ||
| # --------------------------- | ||
| - name: Wait for Dataverse API readiness | ||
| run: | | ||
| set -euo pipefail | ||
| URL="http://localhost:8080/api/info/version" | ||
| MAX_ATTEMPTS=10 | ||
| SLEEP_TIME=15 | ||
| echo "Waiting for Dataverse readiness..." | ||
| for attempt in $(seq 1 $MAX_ATTEMPTS); do | ||
| echo "Attempt $attempt..." | ||
| RESPONSE=$(curl -s --max-time 15 "$URL" || true) | ||
| STATUS=$(echo "$RESPONSE" | jq -r '.status' 2>/dev/null || echo "NOT_READY") | ||
| if [ "$STATUS" = "OK" ]; then | ||
| echo "Dataverse endpoint is READY." | ||
| echo "Dataverse waiting for full readiness. Waiting 30 more seconds." | ||
| sleep 30 | ||
| echo "Response: $RESPONSE" | ||
| exit 0 | ||
| fi | ||
| echo "Not ready. Sleeping ${SLEEP_TIME}s..." | ||
| sleep $SLEEP_TIME | ||
| if [ $SLEEP_TIME -lt 60 ]; then | ||
| SLEEP_TIME=$((SLEEP_TIME * 2)) | ||
| if [ $SLEEP_TIME -gt 60 ]; then | ||
| SLEEP_TIME=60 | ||
| fi | ||
| fi | ||
| done | ||
| echo "Dataverse failed to become ready." | ||
| docker ps | ||
| CONTAINERS="$(docker ps -aq)" | ||
| if [ -n "$CONTAINERS" ]; then | ||
| for cid in $CONTAINERS; do | ||
| echo "===== Logs for container $cid =====" | ||
| docker logs "$cid" || true | ||
| done | ||
| else | ||
| echo "No running containers to show logs for." | ||
| fi | ||
| exit 1 | ||
|
|
||
| # --------------------------- | ||
| # MAP LOCALSTACK TO LOCALHOST | ||
| # --------------------------- | ||
| - name: Map localstack to localhost for Maven tests | ||
| run: echo "127.0.0.1 localstack" | sudo tee -a /etc/hosts | ||
|
|
||
| # --------------------------- | ||
| # CONFIGURE DATAVERSE FOR TESTS | ||
| # --------------------------- | ||
| - name: Configure Dataverse API Settings | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| echo "Setting API Database Settings via internal container curl..." | ||
|
|
||
| # We define the settings in an array | ||
| declare -A settings=( | ||
| [":BuiltinUsersKey"]="burrito" | ||
| [":ProvCollectionEnabled"]="true" | ||
| [":AllowApiTokenLookupViaApi"]="true" | ||
| [":AllowSignUp"]="true" | ||
| ) | ||
| # We run curl INSIDE the container so the source IP is 127.0.0.1 | ||
| for key in "${!settings[@]}"; do | ||
| echo "Setting $key..." | ||
| docker exec dev_dataverse curl -s -X PUT -d "${settings[$key]}" "http://localhost:8080/api/admin/settings/$key" | ||
|
srmanda-cs marked this conversation as resolved.
Outdated
|
||
| echo "" | ||
| done | ||
|
|
||
| # --------------------------- | ||
| # PRE-TEST INJECTIONS (FROM YOUR ALTERNATE WORKFLOWS) | ||
| # --------------------------- | ||
| - name: Put SUSHI config file in place | ||
| run: | | ||
| set -euo pipefail | ||
| # Fixes MakeDataCountApiIT | ||
| docker exec dev_dataverse sh -c 'curl https://raw.githubusercontent.com/IQSS/dataverse/develop/src/test/java/edu/harvard/iq/dataverse/makedatacount/sushi_sample_logs.json > /tmp/sushi_sample_logs.json && head /tmp/sushi_sample_logs.json' | ||
|
srmanda-cs marked this conversation as resolved.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess this will work but would it make more sense to copy the sushi_sample_logs.json file locally rather than downloading it from GitHub? |
||
|
|
||
| # --------------------------- | ||
| # RUN MAVEN TESTS | ||
| # --------------------------- | ||
| - name: Run Maven Integration Tests | ||
| env: | ||
| DVAPIKEY: "burrito" | ||
| DV_APIKEY: "burrito" | ||
| DV_API_KEY: "burrito" | ||
|
Comment on lines
+193
to
+195
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need all three of these? 🌯 🌯 🌯 |
||
| run: | | ||
| set -euo pipefail | ||
| TEST_SUITE=$(cat tests/integration-tests.txt) | ||
|
|
||
| echo "Running suite: $TEST_SUITE" | ||
|
|
||
| # -Dmaven.test.failure.ignore=true forces the JVM to shut down cleanly | ||
| # and write the jacoco.exec file, even when tests fail. | ||
| mvn test \ | ||
| -Dtest="$TEST_SUITE" \ | ||
| -Dmaven.test.failure.ignore=true \ | ||
| -Ddataverse.test.baseurl=http://localhost:8080 \ | ||
| -DcompilerArgument=-Xlint:unchecked | ||
|
|
||
| # --------------------------- | ||
| # GENERATE REPORTS & DEPOSIT TO COVERALLS | ||
| # --------------------------- | ||
| - name: Deposit to Coveralls | ||
| if: always() | ||
| env: | ||
| COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} | ||
| continue-on-error: true | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| # The pom.xml automatically merged the files and put them here: | ||
| mvn coveralls:report \ | ||
| -P all-unit-tests \ | ||
| -DrepoToken=$COVERALLS_REPO_TOKEN \ | ||
| -DjacocoReports=target/site/jacoco-merged-test-coverage-report/jacoco.xml | ||
|
Comment on lines
+221
to
+225
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is probably wrong, but let me verify just in case.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is right, JaCoCo reporting is failing
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this related to why I don't see this branch over at https://coveralls.io/github/IQSS/dataverse ? Check this out:
|
||
|
|
||
| # --------------------------- | ||
| # UPLOAD SUREFIRE/FAILSAFE REPORTS | ||
| # --------------------------- | ||
| - name: Upload Test Failure Reports | ||
| if: always() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: maven-test-reports | ||
| path: | | ||
| target/surefire-reports/ | ||
| target/failsafe-reports/ | ||
| target/site/jacoco/ | ||
| retention-days: 14 | ||
|
|
||
| # --------------------------- | ||
| # 2. PUBLISH TEST DASHBOARD IN GITHUB PR (Optional but highly recommended) | ||
| # --------------------------- | ||
| - name: Publish Test Results Dashboard | ||
| uses: EnricoMi/publish-unit-test-result-action@v2 | ||
| if: always() | ||
| with: | ||
| files: | | ||
| target/failsafe-reports/TEST-*.xml | ||
| target/surefire-reports/TEST-*.xml | ||
|
|
||
| # --------------------------- | ||
| # FAIL WORKFLOW IF TESTS FAILED | ||
| # --------------------------- | ||
| - name: Check for Test Failures | ||
| if: always() | ||
| run: | | ||
| echo "Checking Surefire/Failsafe reports for failures..." | ||
| if grep -q "<failure" target/surefire-reports/*.xml target/failsafe-reports/*.xml 2>/dev/null; then | ||
| echo "Tests failed! Failing the workflow." | ||
| exit 1 | ||
| fi | ||
| echo "All tests passed." | ||
|
|
||
| # --------------------------- | ||
| # COLLECT DOCKER LOGS (ALWAYS, WITH MAPPING) | ||
| # --------------------------- | ||
| - name: Collect Docker logs (mapped) | ||
| if: always() | ||
| run: | | ||
| mkdir -p docker-logs | ||
| echo "Gathering container metadata..." | ||
| docker ps -a --format '{{.Names}}|{{.Image}}|{{.Status}}' > docker-logs/container-summary.txt | ||
| while IFS='|' read -r name image status; do | ||
| # Create a readable label | ||
| label="$name" | ||
| case "$name" in | ||
| *dataverse*) | ||
| label="dataverse-app" | ||
| ;; | ||
| *postgres*) | ||
| label="postgres-db" | ||
| ;; | ||
| *solr*) | ||
| label="solr-index" | ||
| ;; | ||
| *localstack*) | ||
| label="localstack-s3" | ||
| ;; | ||
| esac | ||
| echo "Collecting logs for $name ($label)" | ||
| { | ||
| echo "===== CONTAINER: $name =====" | ||
| echo "Label: $label" | ||
| echo "Image: $image" | ||
| echo "Status: $status" | ||
| echo "" | ||
| echo "===== LOGS =====" | ||
| docker logs --timestamps "$name" 2>&1 || true | ||
| } > "docker-logs/${label}__${name}.log" | ||
| done < docker-logs/container-summary.txt | ||
|
|
||
| # --------------------------- | ||
| # UPLOAD DOCKER LOGS (ALWAYS) | ||
| # --------------------------- | ||
| - name: Upload Docker logs | ||
| if: always() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: docker-logs | ||
| path: docker-logs/ | ||
| retention-days: 7 | ||
|
|
||
| # --------------------------- | ||
| # SHUTDOWN STACK | ||
| # --------------------------- | ||
| - name: Stop Dataverse stack | ||
| if: always() | ||
| run: | | ||
| set -euo pipefail | ||
| mvn -Pct docker:stop || true | ||
|
|
||
| - name: Final Docker cleanup | ||
| if: always() | ||
| run: | | ||
| docker system prune -af || true | ||

Uh oh!
There was an error while loading. Please reload this page.