Skip to content

Commit

Permalink
ci: add github actions (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
pl-buiquang authored Jul 1, 2024
1 parent a809aaf commit 45a2bd1
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 3 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: build
on:
push:
branches:
- "**"

jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: Checkout github repo
uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Build with maven
run: >
./mvnw clean install
- name: Upload the artifact
if: github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v2
with:
name: query-executor

sonar:
runs-on: ubuntu-20.04
steps:
- name: Checkout github repo
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
- name: Run sonarcloud analysis
run: >
./mvnw verify sonar:sonar
-Dsonar.sources=src/main/scala
-Dsonar.tests=src/test/scala
-Dsonar.scala.coverage.reportPaths=target/scoverage.xml
-Dsonar.host.url=https://sonarcloud.io
-Dsonar.organization=aphp
-Dsonar.projectKey=aphp_Cohort360-QueryExecutor
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
27 changes: 27 additions & 0 deletions .github/workflows/commitlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: commitlint

on:
pull_request:
branches:
- 'main'

jobs:
commit-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install commit-lint
run: |
npm install --force conventional-changelog-conventionalcommits @commitlint/config-conventional commitlint@latest
- name: Validate current commit (last commit) with commitlint
if: github.event_name == 'push'
run: npx commitlint --from HEAD~1 --to HEAD --verbose
- name: Validate PR commits with commitlint
if: github.event_name == 'pull_request'
run: npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose
- name: Validate PR title with commitlint
if: github.event_name == 'pull_request'
run: |
echo "${{github.event.pull_request.title}}" | npx commitlint
49 changes: 49 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Publish Docker Image

on:
workflow_run:
workflows: [ "build" ]
types:
- completed

jobs:
build-and-publish:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '11'

- name: Extract version from pom.xml
id: extract_version
run: |
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: query-executor

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
file: ./Dockerfile
push: true
tags: "${{ secrets.DOCKER_USERNAME }}/c360-query-executor:${{ env.VERSION }}"
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# COHORT REQUESTER / SPARK JOB SERVER

[![Actions Status](https://github.com/aphp/Cohort360-QueryExecutor/workflows/build/badge.svg)](https://github.com/aphp/Cohort360-QueryExecutor/actions)
[![Coverage Status](https://sonarcloud.io/api/project_badges/measure?project=aphp_Cohort360-QueryExecutor&metric=coverage)](https://sonarcloud.io/component_measures?id=aphp_Cohort360-QueryExecutor&metric=coverage)
[![Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=aphp_Cohort360-QueryExecutor&metric=alert_status)](https://sonarcloud.io/dashboard?id=aphp_Cohort360-QueryExecutor)

The Cohort Requester is a spark application server for querying FHIR data with a set of criteria and return a count or list of patients that match the criteria.

## Quick Start
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<snapshot.name>SNAPSHOT</snapshot.name>
<compiler.plugin.version>3.6.2</compiler.plugin.version>
<scoverage.plugin.version>1.4.11</scoverage.plugin.version>
<jacoco-maven-plugin.version>0.8.8</jacoco-maven-plugin.version>
<jacoco-maven-plugin.version>0.8.12</jacoco-maven-plugin.version>

</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class RestFhirResolver(fhirClient: RestFhirClient) extends ResourceResolver {
val results: Bundle =
fhirClient.getBundle(
resourceType,
addSourcePopulationConstraint(sourcePopulation, f"_id=${chunk.mkString(",")}"),
addSourcePopulationConstraint(sourcePopulation, f"_id=${chunk.sorted.mkString(",")}"),
getSubsetElementsFilter(resourceQueryColumns.map(c => c.fhirPath))
)
getAllPagesOfResource(results, resourceQueryColumns)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class RestFhirResolverTest extends AnyFunSuiteLike with DatasetComparer {
restFhirClient,
"/resolver/restfhir/testCases/withPatientJoinResource/bundle.patient.json",
FhirResource.PATIENT,
"_id=1900536,1566947&_list=1,2,3,4,5,6,7,8,9,10",
"_id=1566947,1900536&_list=1,2,3,4,5,6,7,8,9,10",
List("birthDate", "id")
)
},
Expand Down

0 comments on commit 45a2bd1

Please sign in to comment.