From a1217969068dddfa03d991323cd7c70130a32d64 Mon Sep 17 00:00:00 2001 From: Marcelle <53578688+m-goggins@users.noreply.github.com> Date: Wed, 16 Oct 2024 11:45:24 -0400 Subject: [PATCH 1/4] move migration 5 to correct location (#26) --- .../flyway/sql/V01_05__insert_nbs_hardcoded_values.sql | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {containers/tefca-viewer => query-connector}/flyway/sql/V01_05__insert_nbs_hardcoded_values.sql (100%) diff --git a/containers/tefca-viewer/flyway/sql/V01_05__insert_nbs_hardcoded_values.sql b/query-connector/flyway/sql/V01_05__insert_nbs_hardcoded_values.sql similarity index 100% rename from containers/tefca-viewer/flyway/sql/V01_05__insert_nbs_hardcoded_values.sql rename to query-connector/flyway/sql/V01_05__insert_nbs_hardcoded_values.sql From dd3e4a28d631832f94446b920120f3af748d2638 Mon Sep 17 00:00:00 2001 From: Daniel Paseltiner <99684231+DanPaseltiner@users.noreply.github.com> Date: Wed, 16 Oct 2024 12:07:52 -0400 Subject: [PATCH 2/4] First draft of CD workflow (#27) --- .github/workflows/cd.yaml | 43 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/cd.yaml diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml new file mode 100644 index 000000000..57894ef23 --- /dev/null +++ b/.github/workflows/cd.yaml @@ -0,0 +1,43 @@ +name: CD + +on: + merge_group: + types: + - checks_requested + push: + branches: + - main + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + name: Build Query Connector Image + runs-on: ubuntu-latest + permissions: + contents: "read" + id-token: "write" + packages: "write" + steps: + - name: Check Out Changes + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v3 + working-directory: ./query-connector + with: + push: true + tags: [main, latest] From f4801c39bb5cbe54848f4c419a6df6d94ba3f560 Mon Sep 17 00:00:00 2001 From: Daniel Paseltiner <99684231+DanPaseltiner@users.noreply.github.com> Date: Wed, 16 Oct 2024 12:26:44 -0400 Subject: [PATCH 3/4] Update cd.yaml (#28) --- .github/workflows/cd.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml index 57894ef23..830742367 100644 --- a/.github/workflows/cd.yaml +++ b/.github/workflows/cd.yaml @@ -37,7 +37,7 @@ jobs: - name: Build and push uses: docker/build-push-action@v3 - working-directory: ./query-connector with: + context: ./query-connector push: true - tags: [main, latest] + tags: ghcr.io/${{ github.repository }}/query-connector:main, ghcr.io/${{ github.repository }}/query-connector:latest From af54b91ce94198cff7c1ae6c380d99e1b149836d Mon Sep 17 00:00:00 2001 From: Daniel Paseltiner <99684231+DanPaseltiner@users.noreply.github.com> Date: Wed, 16 Oct 2024 12:56:50 -0400 Subject: [PATCH 4/4] Removing old workflows we don't need anymore (#29) --- .github/workflows/buildReleaseContainers.yaml | 82 ----- .github/workflows/createNewRelease.yaml | 285 ------------------ .github/workflows/run-container-workflow.yaml | 19 -- 3 files changed, 386 deletions(-) delete mode 100644 .github/workflows/buildReleaseContainers.yaml delete mode 100644 .github/workflows/createNewRelease.yaml delete mode 100644 .github/workflows/run-container-workflow.yaml diff --git a/.github/workflows/buildReleaseContainers.yaml b/.github/workflows/buildReleaseContainers.yaml deleted file mode 100644 index c809d5c37..000000000 --- a/.github/workflows/buildReleaseContainers.yaml +++ /dev/null @@ -1,82 +0,0 @@ -name: Build Release Specific Containers - -on: - workflow_call: - inputs: - container-tag: - type: string - required: true - workflow_dispatch: - inputs: - container-tag: - type: string - required: true - -jobs: - list-containers: - uses: ./.github/workflows/listContainers.yaml - build: - name: Build containers - needs: list-containers - runs-on: ubuntu-latest - strategy: - matrix: - container-to-build: ${{fromJson(needs.list-containers.outputs.all-containers)}} - permissions: - contents: "read" - id-token: "write" - packages: "write" - steps: - - name: Check Out Changes - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ inputs.container-tag }} - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Log in to the Container registry - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v4 - with: - ref: ${{ inputs.container-tag }} - images: ghcr.io/${{ github.repository }}/${{matrix.container-to-build}} - # this sets the version for tags and labels for each of the containers to be - # be the same as the version/tag where the code was pulled from - tags: | - type=semver,pattern={{raw}},value=${{ inputs.container-tag }} - type=ref,event=branch - type=ref,event=tag,pattern={{raw}},value=${{ inputs.container-tag }} - labels: | - org.opencontainers.image.version=${{ inputs.container-tag }} - - - name: Build and push - uses: docker/build-push-action@v3 - if: ${{ !contains(fromJSON('["ecr-viewer", "tefca-viewer"]'), matrix.container-to-build) }} - with: - context: ./containers/${{matrix.container-to-build}} - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max - - - name: Build and push with shared-resources - uses: docker/build-push-action@v3 - if: ${{ contains(fromJSON('["ecr-viewer", "tefca-viewer"]'), matrix.container-to-build) }} - with: - context: . - file: ./containers/${{ matrix.container-to-build }}/Dockerfile - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max diff --git a/.github/workflows/createNewRelease.yaml b/.github/workflows/createNewRelease.yaml deleted file mode 100644 index 8468c7229..000000000 --- a/.github/workflows/createNewRelease.yaml +++ /dev/null @@ -1,285 +0,0 @@ -name: Create New Release -on: - workflow_dispatch: - push: - branches: - - main - -# Run all tests before making a release -jobs: - # Only make a release if commit contains [RELEASE] - check-commit-message: - runs-on: ubuntu-latest - outputs: - contains_release: ${{ steps.commit_check.outputs.contains_release }} - steps: - - name: Check out code - uses: actions/checkout@v4 - - name: Check commit message for [RELEASE] - id: commit_check - run: | - if [[ "${{ github.event.head_commit.message }}" == *"[RELEASE]"* ]]; then - echo "contains_release=true" >> $GITHUB_OUTPUT - else - echo "contains_release=false" >> $GITHUB_OUTPUT - fi - list-containers: - needs: check-commit-message - if: ${{ needs.check-commit-message.outputs.contains_release == 'true' }} - uses: ./.github/workflows/listContainers.yaml - - test-for-release: - needs: - - check-commit-message - - list-containers - if: ${{ needs.check-commit-message.outputs.contains_release == 'true' }} - strategy: - matrix: - container: ${{fromJson(needs.list-containers.outputs.all-containers)}} - uses: ./.github/workflows/run-container-workflow.yaml - with: - container: ${{ matrix.container }} - secrets: inherit - - tag-release: - name: Update phdi init version number - needs: test-for-release - permissions: - contents: write - outputs: - version: ${{ steps.get_version.outputs.version }} - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: "0" - ref: "main" - - name: Install poetry and dependencies - run: | - pip install poetry - # update the version number in the phdi/__init.py__ file - - name: Get PHDI Version - id: get_version - run: | - VERSION_WITH_PHDI=$(poetry version) - echo "version=${VERSION_WITH_PHDI:5}" >> $GITHUB_OUTPUT - # Create new release tag - - name: Set up Git user - run: | - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" - - name: Tag Release - uses: EndBug/latest-tag@latest - with: - ref: ${{ steps.get_version.outputs.version }} - # Generate release notes - - name: Generate release notes - id: release_notes - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - latest_release_date=$(gh api "/repos/$GITHUB_REPOSITORY/releases?per_page=1" | jq ".[0].created_at") - prs=$(gh pr list --base main --state closed --json title,number,url,closedAt -q ".[] | select(.closedAt > $latest_release_date) | select(.title | contains(\"RELEASE\") | not)") - - echo "# Release Notes" > release-notes.md - echo "" >> release-notes.md - echo "" >> release-notes.md - - while IFS= read -r pr; do - pr_title=$(echo "$pr" | jq -r ".title") - pr_number=$(echo "$pr" | jq -r ".number") - pr_url=$(echo "$pr" | jq -r ".url") - line_text="- $pr_title ([#$pr_number]($pr_url))" - echo $line_text >> release-notes.md - done < <(printf '%s' "$prs") - - # Create new release based upon the latest created tag - - name: Create Release - id: create_release - uses: actions/create-release@v1.1.4 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ steps.get_version.outputs.version }} - release_name: ${{ steps.get_version.outputs.version }} - body_path: release-notes.md - - release-to-pypi: - name: Build and publish PHDI to PyPI - needs: tag-release - runs-on: ubuntu-latest - permissions: - id-token: write - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: "0" - ref: ${{ needs.tag-release.outputs.version }} - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: "3.x" - - name: Install pypa/build - run: >- - python -m - pip install - build - --user - - name: Build a binary wheel and a source tarball - run: >- - python -m - build - --sdist - --wheel - --outdir dist/ - . - - name: Publish distribution 📦 to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - password: ${{ secrets.PYPI_API_TOKEN }} - - # Rebuild all containers for the new release - build-containers-for-release: - needs: - - tag-release - - release-to-pypi - permissions: - contents: read - packages: write - id-token: write - uses: ./.github/workflows/buildReleaseContainers.yaml - with: - container-tag: ${{ needs.tag-release.outputs.version }} - - # Create updated PHDI docs for the latest release - generate-and-update-phdi-docs: - needs: - - tag-release - - build-containers-for-release - permissions: - contents: write - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: "0" - ref: ${{ needs.tag-release.outputs.version }} - - - name: Install poetry and dependencies - run: | - pip install poetry - poetry install - - - name: Set environment variable for pdoc - run: echo "PDOC_ALLOW_EXEC=1" >> $GITHUB_ENV - - - name: Clear Poetry Cache - run: | - poetry cache clear pypi --all - poetry cache clear virtualenvs --all - - - name: Generate docs and move to docs branch - run: | - poetry run pdoc ./phdi -o ./docs/${{ needs.tag-release.outputs.version }}/sdk - - - uses: actions/upload-artifact@v3 - with: - name: phdi-docs - path: ./docs/${{ needs.tag-release.outputs.version }}/sdk - - # Create updated container docs for the latest release - generate-and-update-container-docs: - needs: - - tag-release - - list-containers - - generate-and-update-phdi-docs - permissions: - contents: write - runs-on: ubuntu-latest - services: - test-db: - image: postgres:13-alpine3.16 - env: - POSTGRES_PASSWORD: pw - POSTGRES_DB: testdb - POSTGRES_USER: postgres - # Set health checks to wait until postgres has started - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - --name testdb - ports: - - 5432:5432 - strategy: - matrix: - container: ${{fromJson(needs.list-containers.outputs.python-containers)}} - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: "0" - ref: ${{ needs.tag-release.outputs.version }} - - - name: Update Container Documentation - env: - MPI_DBNAME: testdb - MPI_PASSWORD: pw - MPI_DB_TYPE: postgres - MPI_HOST: localhost - MPI_USER: postgres - MPI_PORT: 5432 - MPI_PATIENT_TABLE: patient - MPI_PERSON_TABLE: person - run: | - npm i -g redoc-cli - CONTAINER=${{ matrix.container }} - cd $GITHUB_WORKSPACE/containers/$CONTAINER - cp $GITHUB_WORKSPACE/utils/make_openapi_json.py . - pip install -r requirements.txt - python make_openapi_json.py - redoc-cli build -o $GITHUB_WORKSPACE/docs/${{ needs.tag-release.outputs.version }}/containers/$CONTAINER.html openapi.json - - - uses: actions/upload-artifact@v3 - with: - name: container-docs - path: ./docs/${{ needs.tag-release.outputs.version }}/containers - - commit-docs: - needs: - - tag-release - - generate-and-update-phdi-docs - - generate-and-update-container-docs - permissions: - contents: write - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - ref: docs - - - name: Download phdi docs from artifacts - uses: actions/download-artifact@v4.1.7 - with: - name: phdi-docs - path: ./docs/${{ needs.tag-release.outputs.version }}/sdk - - - name: Download container docs from artifacts - uses: actions/download-artifact@v4.1.7 - with: - name: container-docs - path: ./docs/${{ needs.tag-release.outputs.version }}/containers - - - name: Copy to latest folder - run: | - rm -rf ./docs/latest - mkdir -p ./docs/latest/sdk - mkdir -p ./docs/latest/containers - cp -r ./docs/${{ needs.tag-release.outputs.version }}/sdk/* ./docs/latest/sdk - cp -r ./docs/${{ needs.tag-release.outputs.version }}/containers/* ./docs/latest/containers - - - name: Commit New Documentation - uses: EndBug/add-and-commit@v9 - with: - add: docs - message: Automated update of docs for ${{ needs.tag-release.outputs.version }} release. diff --git a/.github/workflows/run-container-workflow.yaml b/.github/workflows/run-container-workflow.yaml deleted file mode 100644 index fd942e81f..000000000 --- a/.github/workflows/run-container-workflow.yaml +++ /dev/null @@ -1,19 +0,0 @@ -name: "Run Container Workflow" -on: - workflow_call: - inputs: - container: - required: true - type: string -jobs: - run-container-workflow: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Run specified workflow - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh workflow run .github/workflows/container-${{ inputs.container }}.yaml