Get FAIR Data Team dependencies from Maven Central repository (#577) #1012
This file contains 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: "Test & Build" | |
on: | |
push: | |
pull_request: | |
jobs: | |
test: | |
name: Test | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- ubuntu-22.04 | |
- windows-2022 | |
- macos-12 | |
runs-on: ${{ matrix.os }} | |
env: | |
JAVA_DISTRIBUTION: temurin | |
JAVA_VERSION: 21 | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup PostgreSQL DB | |
if: matrix.os != 'macos-12' # macOS is too slow for tests in GitHub Actions | |
uses: ikalnytskyi/action-setup-postgres@v6 | |
id: postgres | |
with: | |
username: fdp | |
password: fdp | |
database: fdp_test | |
port: 54321 | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: ${{ env.JAVA_DISTRIBUTION }} | |
java-version: ${{ env.JAVA_VERSION }} | |
cache: 'maven' | |
- name: Compile | |
run: | | |
mvn -q -U -B compile | |
- name: Test | |
if: matrix.os != 'macos-12' # macOS is too slow for tests in GitHub Actions | |
run: | | |
mvn -q -U -B test | |
env: | |
FDP_POSTGRES_HOST: localhost | |
FDP_POSTGRES_PORT: 54321 | |
FDP_POSTGRES_DB: fdp_test | |
FDP_POSTGRES_USERNAME: fdp | |
FDP_POSTGRES_PASSWORD: fdp | |
- name: Package | |
run: | | |
mvn -q -U -B -ff -DskipTests package | |
- name: Verify | |
run: | | |
mvn -q -U -B -ff -DskipTests verify | |
docker: | |
name: Docker build | |
runs-on: ubuntu-latest | |
needs: test | |
env: | |
PUBLIC_IMAGE: fairdata/fairdatapoint | |
PRIVATE_IMAGE: ${{ secrets.PRIVATE_REGISTRY_URL }}/fairdatapoint | |
PRIVATE_REGISTRY_URL: ${{ secrets.PRIVATE_REGISTRY_URL }} | |
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Check available platforms | |
run: echo ${{ steps.buildx.outputs.platforms }} | |
- name: Docker meta [test] | |
id: meta-test | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
${{ env.PUBLIC_IMAGE }} | |
tags: | | |
type=sha | |
- name: Docker build+push [test] | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./Dockerfile.build | |
platforms: linux/amd64,linux/arm64 | |
push: false | |
tags: ${{ steps.meta-test.outputs.tags }} | |
labels: ${{ steps.meta-test.outputs.labels }} | |
# PRIVATE: DOCKER REGISTRY | |
- name: Docker login [private] | |
if: github.event_name == 'push' && env.PRIVATE_REGISTRY_URL != '' | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ secrets.PRIVATE_REGISTRY_URL }} | |
username: ${{ secrets.PRIVATE_REGISTRY_USERNAME }} | |
password: ${{ secrets.PRIVATE_REGISTRY_PASSWORD }} | |
- name: Docker meta [private] | |
id: meta-private | |
if: github.event_name == 'push' && env.PRIVATE_REGISTRY_URL != '' | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
${{ env.PRIVATE_IMAGE }} | |
tags: | | |
type=ref,event=branch | |
type=semver,pattern={{version}} | |
- name: Docker build+push [private] | |
uses: docker/build-push-action@v5 | |
if: github.event_name == 'push' && env.PRIVATE_REGISTRY_URL != '' && steps.meta-private.outputs.tags != '' | |
with: | |
context: . | |
file: ./Dockerfile.build | |
platforms: linux/amd64,linux/arm64 | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta-private.outputs.tags }} | |
labels: ${{ steps.meta-private.outputs.labels }} | |
# PUBLIC: DOCKER HUB | |
- name: Docker login [public] | |
if: github.event_name == 'push' && env.DOCKER_HUB_USERNAME != '' | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_PASSWORD }} | |
- name: Docker meta [public] | |
id: meta-public | |
if: github.event_name == 'push' && env.DOCKER_HUB_USERNAME != '' | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
${{ env.PUBLIC_IMAGE }} | |
tags: | | |
type=raw,value=develop,enable=${{ github.ref == format('refs/heads/{0}', 'develop') }} | |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }} | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }} | |
- name: Docker build+push [public] | |
uses: docker/build-push-action@v5 | |
if: github.event_name == 'push' && env.DOCKER_HUB_USERNAME != '' && steps.meta-public.outputs.tags != '' | |
with: | |
context: . | |
file: ./Dockerfile.build | |
platforms: linux/amd64,linux/arm64 | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta-public.outputs.tags }} | |
labels: ${{ steps.meta-public.outputs.labels }} |