Add qualifier as default dimension for cloudwatch metrics retrieval #4860
Workflow file for this run
This file contains hidden or 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
name: CI | |
on: | |
push: | |
pull_request: | |
env: | |
python-version: '3.11' | |
java-version: '17' | |
gradle-version: '8.12.1' | |
node-version: '18.x' | |
gradle-test-parallelization: '30' | |
# Prevent multiple simultaneous runs except on main repo | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }} | |
cancel-in-progress: ${{ !(github.event_name == 'push' && github.repository == 'opensearch-project/opensearch-migrations') }} | |
jobs: | |
generate-cache-key: | |
runs-on: ubuntu-latest | |
outputs: | |
docker_cache_key: ${{ steps.generate_docker_cache_key.outputs.key }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Generate Docker Cache Key | |
id: generate_docker_cache_key | |
run: | | |
files=$(find . -type f \( -name 'docker-compose.yml' -o -name 'Dockerfile' \)) | |
file_contents=$(cat $files) | |
key=$(echo "${file_contents}" | sha1sum | awk '{print $1}') | |
echo "key=${key}" >> "$GITHUB_OUTPUT" | |
workflow-info: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Create JSON Artifact | |
run: | | |
echo '{' > workflow-info.json | |
echo ' "pr_number": "${{ github.event.pull_request.number }}",' >> workflow-info.json | |
echo ' "commit": "${{ github.event.pull_request.head.sha || github.event.after || github.sha }}",' >> workflow-info.json | |
echo ' "branch": "${{ github.ref }}",' >> workflow-info.json | |
echo ' "commit_parent": "${{ github.event.pull_request.base.sha || github.event.before || github.base.sha }}",' >> workflow-info.json | |
echo ' "build_url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",' >> workflow-info.json | |
echo ' "build": "${{ github.run_id }}"' >> workflow-info.json | |
echo '}' >> workflow-info.json | |
echo "workflow-info.json created" | |
- name: Upload JSON Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: workflow-info | |
path: workflow-info.json | |
gradle-extended-check: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
tasks: | |
- spotlessCheck | |
- publishToMavenLocal | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-java@v4 | |
with: | |
java-version: ${{ env.java-version }} | |
distribution: "corretto" | |
- uses: gradle/actions/setup-gradle@v4 | |
with: | |
gradle-version: ${{ env.gradle-version }} | |
- name: Run Gradle Build | |
run: gradle ${{matrix.tasks}} | |
env: | |
OS_MIGRATIONS_GRADLE_SCAN_TOS_AGREE_AND_ENABLED: '' | |
python-lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.python-version }} | |
- name: Install dependencies | |
run: | | |
python3 -m pip install --upgrade pip | |
python3 -m pip install flake8 | |
- name: Analysing the code with flake8 | |
run: | | |
flake8 $(git ls-files '*.py') | |
python-tests: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
py-project: | |
- migrationConsole/lib/console_link | |
- migrationConsole/cluster_tools | |
- migrationConsole/console_api | |
- k8sConfigMapUtilScripts | |
env: | |
WORKING_DIR: ./TrafficCapture/dockerSolution/src/main/docker/${{ matrix.py-project }} | |
defaults: | |
run: | |
working-directory: ${{ env.WORKING_DIR }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.python-version }} | |
- run: | | |
python3 -m pip install --upgrade pipenv | |
pipenv install --deploy --dev | |
pipenv run test | |
pipenv run coverage xml | |
- name: Get Sanitized Name | |
env: | |
PY_PROJECT: ${{ matrix.py-project }} | |
run: echo "SANITIZED_PY_PROJECT=${PY_PROJECT//\//-}" >> $GITHUB_ENV | |
- name: Upload Coverage Reports | |
uses: actions/upload-artifact@v4 | |
with: | |
if-no-files-found: error | |
name: coverage-reports-python-tests-${{ env.SANITIZED_PY_PROJECT }} | |
path: ${{ env.WORKING_DIR }}/coverage.xml | |
generate-test-matrix: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- id: set-matrix | |
run: | | |
# Generate a JSON array from 0 to gradle-test-parallelization-1 | |
indices=() | |
for i in $(seq 0 $((${{ env.gradle-test-parallelization }}-1))); do | |
indices+=($i) | |
done | |
echo "matrix=$(IFS=,; echo "[${indices[*]}]")" >> $GITHUB_OUTPUT | |
gradle-tests: | |
needs: [generate-test-matrix, generate-cache-key] | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
index: ${{ fromJson(needs.generate-test-matrix.outputs.matrix) }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-java@v4 | |
with: | |
java-version: ${{ env.java-version }} | |
distribution: 'corretto' | |
- uses: gradle/actions/setup-gradle@v4 | |
with: | |
gradle-version: ${{ env.gradle-version }} | |
gradle-home-cache-cleanup: true | |
- name: Restore Docker Cache | |
uses: AndreKurait/[email protected] | |
with: | |
key: docker-${{ runner.os }}-${{ needs.generate-cache-key.outputs.docker_cache_key }} | |
# Delegate cache saving to python-e2e-tests | |
read-only: true | |
- name: Run Gradle tests with striping | |
run: | | |
MAX_WORKERS=$(( $(nproc) - 1 )) | |
gradle allTests \ | |
--max-workers $MAX_WORKERS \ | |
-Dtest.striping.total=${{ env.gradle-test-parallelization }} \ | |
-Dtest.striping.index=${{ matrix.index }} \ | |
-x spotlessCheck --stacktrace --continue | |
env: | |
OS_MIGRATIONS_GRADLE_SCAN_TOS_AGREE_AND_ENABLED: '' | |
- name: Detect Memory Dumps | |
if: failure() | |
run: | | |
if find . -type f -name "*.hprof" | grep -q '.'; then | |
echo "::group::Memory Dumps Detected" | |
echo "::warning::Memory dumps were found and uploaded as artifacts. Review these files to diagnose OOM issues." | |
echo "To download and inspect these files, navigate to 'Actions' -> 'Artifacts'." | |
echo "::endgroup::" | |
fi | |
- name: Upload memory dump | |
if: failure() | |
uses: actions/upload-artifact@v4 | |
with: | |
if-no-files-found: warn | |
name: memory-dumps-gradle-tests-stripe-${{ matrix.index }} | |
path: ./**/*.hprof | |
- name: Upload test reports for stripe ${{ matrix.index }} | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
if-no-files-found: error | |
name: test-reports-gradle-tests-stripe-${{ matrix.index }} | |
path: | | |
**/build/reports/tests/ | |
- name: Publish Jacoco report artifact for stripe ${{ matrix.index }} | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
if-no-files-found: error | |
name: coverage-exec-artifacts-gradle-tests-stripe-${{ matrix.index }} | |
path: | | |
**/build/jacoco/*.exec | |
jacoco-aggregate: | |
needs: [ gradle-tests ] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-java@v4 | |
with: | |
java-version: ${{ env.java-version }} | |
distribution: 'corretto' | |
- uses: gradle/actions/setup-gradle@v4 | |
with: | |
gradle-version: ${{ env.gradle-version }} | |
- name: Create clean .exec directory | |
run: rm -rf build/jacocoMerged && mkdir -p build/jacocoMerged | |
- name: Download all JaCoCo .exec files into directory expected by jacocoAggregateReport | |
uses: actions/download-artifact@v4 | |
with: | |
path: build/jacocoMerged | |
pattern: coverage-exec-artifacts-gradle-tests-* | |
merge-multiple: true | |
- name: Generate aggregate JaCoCo report | |
run: gradle jacocoAggregateReport -x spotlessCheck --info --stacktrace | |
env: | |
OS_MIGRATIONS_GRADLE_SCAN_TOS_AGREE_AND_ENABLED: '' | |
- name: Upload Aggregate JaCoCo report | |
uses: actions/upload-artifact@v4 | |
with: | |
if-no-files-found: error | |
name: coverage-reports-gradle-tests-aggregate | |
path: | | |
**/jacocoMergedReport.xml | |
python-e2e-tests: | |
needs: [ generate-cache-key ] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-java@v4 | |
with: | |
java-version: ${{ env.java-version }} | |
distribution: 'corretto' | |
- uses: gradle/actions/setup-gradle@v4 | |
with: | |
gradle-version: ${{ env.gradle-version }} | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.python-version }} | |
- name: Cache Docker Images | |
uses: AndreKurait/[email protected] | |
with: | |
key: docker-${{ runner.os }}-${{ needs.generate-cache-key.outputs.docker_cache_key }} | |
# Only save cache on push events | |
read-only: ${{ github.event_name != 'push' }} | |
- name: Start Docker Solution | |
run: gradle -p TrafficCapture dockerSolution:ComposeUp -x test -x spotlessCheck --info --stacktrace | |
env: | |
OS_MIGRATIONS_GRADLE_SCAN_TOS_AGREE_AND_ENABLED: '' | |
- name: Run E2E test script | |
run: | | |
docker exec $(docker ps --filter "name=migration-console" -q) pipenv run pytest /root/lib/integ_test/integ_test/replayer_tests.py --unique_id="testindex" -s | |
- name: Collect Docker, OpenSearch Benchmark, and Shared Logs | |
if: always() | |
run: | | |
mkdir -p logs/docker logs/opensearch_benchmark_logs logs/shared_logs_output | |
for container in $(docker ps -aq); do | |
container_name=$(docker inspect --format '{{.Name}}' $container | sed 's/\///') | |
docker logs $container > logs/docker/${container_name}_logs.txt 2>&1 | |
done | |
docker cp $(docker ps --filter "name=migration-console" -q):/root/.benchmark/logs logs/opensearch_benchmark_logs | |
docker cp $(docker ps --filter "name=migration-console" -q):/shared-logs-output logs/shared_logs_output | |
- name: Upload Logs | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
if-no-files-found: error | |
name: e2e-test-logs | |
path: | | |
logs/docker | |
logs/opensearch_benchmark_logs | |
logs/shared_logs_output | |
- name: Clean up migrations docker images before caching | |
run: | | |
docker stop $(docker ps -q) && docker system prune --volumes -f | |
docker image ls --format '{{.Repository}}:{{.Tag}}' | grep '^migrations/' | xargs -I {} docker image rm {} | |
node-tests: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
npm-project: | |
- ./deployment/cdk/opensearch-service-migration | |
- ./deployment/migration-assistant-solution | |
- ./frontend | |
defaults: | |
run: | |
working-directory: ${{ matrix.npm-project }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.node-version }} | |
- name: Install NPM dependencies | |
run: npm ci | |
- name: Run CDK Jest Tests (using mocked images) | |
run: npm run test | |
link-checker: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: lychee Link Checker | |
id: lychee | |
uses: lycheeverse/lychee-action@v2 | |
with: | |
args: --verbose --accept=200,403,429 "**/*.html" "**/*.md" "**/*.txt" "**/*.json" | |
--offline | |
--exclude "file:///github/workspace/*" | |
--exclude "http://localhost*" | |
--exclude "https://localhost*" | |
--exclude "http://capture-proxy*" | |
--exclude "https://capture-proxy*" | |
--exclude-path "TrafficCapture/dockerSolution/src/main/docker/k8sConfigMapUtilScripts/tests/data" | |
--exclude-mail | |
fail: true | |
env: | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
all-ci-checks-pass: | |
needs: | |
- python-tests | |
- gradle-tests | |
- jacoco-aggregate | |
- link-checker | |
- node-tests | |
- python-e2e-tests | |
- python-lint | |
- gradle-extended-check | |
if: always() | |
runs-on: ubuntu-latest | |
steps: | |
- if: ${{ contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'failure') || contains(needs.*.result, 'skipped') }} | |
run: | | |
echo "One or more job cancelled, failed, or skipped" && exit 1 | |
- run: | | |
echo '## :heavy_check_mark: All continuous integration checks pass' >> $GITHUB_STEP_SUMMARY |