Skip to content

Commit

Permalink
FAIRSPC-23: test outputs (#1452)
Browse files Browse the repository at this point in the history
  • Loading branch information
tgreenwood authored Dec 19, 2023
1 parent 303cafa commit d23e18a
Showing 1 changed file with 125 additions and 125 deletions.
250 changes: 125 additions & 125 deletions .github/workflows/build_and_upload_on_push_to_dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,46 @@ env:
DOCKER_REGISTRY: ghcr.io

#TODO: remove '-x test'
#TODO: transfer tag label
#TODO: look for travis and create tickets

on:
push:
branches:
- "dev"
- "infra/FAIRSPC-23_github_actions_CI"

jobs:
build-saturn:
generate-version: # to have one common unique version for all built artifacts per build cycle
runs-on: ubuntu-latest
outputs:
output1: ${{ steps.version.outputs.snapshot_version }}
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Initialization
- id: version #TODO: introduce release version generation strategy
name: Generating version tag for artifacts (Snapshot only)
run: |
# VERSION
# EXTRACT VERSION
BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
echo "branch: $BRANCH"
echo "Building images from the branch: $BRANCH"
VER=$(cat ./VERSION)
if [ $BRANCH == "dev" ]
then
VER=$VER-$BRANCH
fi
echo "VERSION=$VER" >> $GITHUB_ENV
echo "version: $VER"
# GET DATE AND TIME FOR VERSIONING
echo "Building images of version: $VER"
# GET DATE AND TIME FOR VERSIONING
DATE=$(date "+%Y%m%d%H%M%S")
echo "DATE=$DATE" >> $GITHUB_ENV
echo "Current date for versioning: $DATE"
# DOCKER TAG TO BE ATTACHED (SHARED WITHIN OUTPUT):
SNAPSHOT_VERSION=SNAPSHOT-$VER-$DATE
echo "snapshot_version=$SNAPSHOT_VERSION" >> "$GITHUB_OUTPUT"
echo "Docker tag to be attached to images: $SNAPSHOT_VERSION"
# DOCKER TAG TO BE ATTACHED:
echo "Docker tag to be attached to images: SNAPSHOT-$VER-$DATE"
build-saturn:
runs-on: ubuntu-latest
needs: generate-version
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v3
Expand All @@ -53,132 +59,126 @@ jobs:
run: ./projects/saturn/gradlew build -p ./projects/saturn/ -x test

- name: Log in to the Container registry
# if: env.DO_BUILD_IMAGES_AND_PUBLISH == true
uses: docker/login-action@v3
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
# if: env.DO_BUILD_IMAGES_AND_PUBLISH == true
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ github.repository }}/saturn

- name: Build and push Docker image
# if: env.DO_BUILD_IMAGES_AND_PUBLISH == true
env:
SNAPSHOT_VERSION: ${{needs.generate-version.outputs.output1}}
uses: docker/build-push-action@v5
with:
context: ./projects/saturn/
push: true
tags: ${{ env.DOCKER_REGISTRY }}/${{ github.repository }}/saturn:SNAPSHOT-${{ env.VERSION }}-${{ env.DATE }}
tags: ${{ env.DOCKER_REGISTRY }}/${{ github.repository }}/saturn:${{needs.generate-version.outputs.output1}}
labels: ${{ steps.meta.outputs.labels }}

# build-mercury:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
#
# - name: Set Node.js 18.x
# uses: actions/setup-node@v3
# with:
# node-version: 18.x
# - name: Get version
# run: |
# BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
# echo "branch: $BRANCH"
# VER=$(cat ./VERSION)
# if [ $BRANCH == "dev" ]
# then
# VER=$VER-$BRANCH
# fi
# echo "VERSION=$VER" >> $GITHUB_ENV
# echo "version: $VER"
# - name: Set deployment version
# run: |
# sed -i "s/0.0.0-RELEASEVERSION/${{ env.VERSION }}/g" projects/mercury/package.json
#
# - name: Run install
# uses: borales/actions-yarn@v4
# with:
# cmd: install # will run `yarn install`
# dir: ./projects/mercury/
# - name: Build production bundle

build-mercury:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x

- name: Set deployment version
run: |
sed -i "s/0.0.0-RELEASEVERSION/${{needs.generate-version.outputs.output1}}/g" projects/mercury/package.json
- name: Run install
uses: borales/actions-yarn@v4
with:
cmd: install # will run `yarn install`
dir: ./projects/mercury/

- name: Build Mercury bundle
uses: borales/actions-yarn@v4
with:
cmd: build # will run `yarn build`
dir: ./projects/mercury/

- name: Upload generated artifacts for further # to be used building an image which includes artifacts of both Pluto and Mercury
uses: actions/upload-artifact@v4
with:
name: mercury-build
path: ./projects/mercury/build/

# - name: Run Mercury tests
# uses: borales/actions-yarn@v4
# with:
# cmd: build # will run `yarn build'
# cmd: test # will run `yarn test`
# dir: ./projects/mercury/
# - uses: actions/upload-artifact@v3
# with:
# name: mercury-build
# path: ./projects/mercury/build/
# # todo: enable tests
# # - name: Test the app
# # uses: borales/actions-yarn@v4
# # with:
# # cmd: test # will run `yarn test`
# # dir: ./projects/mercury/

# build-pluto:
# needs: build-mercury
# runs-on: ubuntu-latest
# permissions:
# contents: read
# id-token: write
# packages: write
#
# steps:
# - uses: actions/checkout@v3
#
# - name: Set variables
# run: |
# BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
# echo "branch: $BRANCH"
# VER=$(cat ./VERSION)
# if [ $BRANCH == "dev" ]
# then
# VER=$VER-$BRANCH
# fi
#
# echo "VERSION=$VER" >> $GITHUB_ENV
# echo "version: $VER"
#
# - name: Set up JDK 17
# uses: actions/setup-java@v3
# with:
# java-version: '17'
# distribution: 'temurin'
# - name: Change wrapper permissions
# run: chmod +x ./projects/pluto/gradlew
# - name: Build with Gradle
# run: ./projects/pluto/gradlew build -p ./projects/pluto/
#
# # mercury frontend will be hosted in the same pod as pluto
# - uses: actions/download-artifact@v3
# with:
# name: mercury-build
# path: ./projects/pluto/build/mercury
#
# - name: Log in to the Container registry
# uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
# with:
# registry: ${{ env.REGISTRY }}
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
#
# - name: Extract metadata (tags, labels) for Docker
# id: meta
# uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
# with:
# images: ghcr.io/${{ github.repository }}/pluto
#
# # todo: copy mercury build artifact to pluto build folder (see pluto docker file for location)
# - name: Build and push Docker image
# uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
# with:
# context: ./projects/pluto/
# push: ${{ github.event_name != 'pull_request' }}
# tags: ghcr.io/${{ github.repository }}/pluto:${{ env.VERSION }}
# labels: ${{ steps.meta.outputs.labels }}

build-pluto:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4

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

- name: Build with Gradle
run: ./projects/pluto/gradlew build -p ./projects/pluto/ -x test

- name: Upload generated artifacts for further # to be used building an image which includes artifacts of both Pluto and Mercury
uses: actions/upload-artifact@v4
with:
name: pluto-build
path: ./projects/pluto/build/distributions/*.tar


build-docker-image-with-pluto-and-mercury:
needs: [generate-version, build-mercury, build-pluto]
runs-on: ubuntu-latest
steps:
- name: Check out repository # To get Pluto Dockerfile
uses: actions/checkout@v4

- name: Download Mercury artifacts
uses: actions/download-artifact@v4
with:
name: mercury-build
path: ./projects/pluto/build/mercury

- name: Download Pluto artifacts
uses: actions/download-artifact@v4
with:
name: pluto-build
path: ./projects/pluto/build/distributions/

- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ github.repository }}/pluto

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./projects/pluto/
push: true
tags: ${{ env.DOCKER_REGISTRY }}/${{ github.repository }}/pluto:${{needs.generate-version.outputs.output1}}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit d23e18a

Please sign in to comment.