Skip to content

Commit

Permalink
build: migrate build to GitHub Actions
Browse files Browse the repository at this point in the history
Add pull request file, master and release branches files to be used by the GitHub actions to check the PRs.

ING-4164

build: migrate build to GitHub Actions

Add pull request file, master and release branches files to be used by the GitHub actions to check the PRs.

ING-4164
  • Loading branch information
emanuelaepure10 committed Apr 18, 2024
1 parent 1190433 commit 8a6ca3c
Show file tree
Hide file tree
Showing 5 changed files with 208 additions and 38 deletions.
74 changes: 37 additions & 37 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
name: Check
name: Pull Request Workflow

# XXX disabled for now because we use Jenkins still, but at the time this was tested it was functional
# on:
# pull_request:
# branches: [ master ]
on:
pull_request:
branches:
- '*' # Trigger on all branches for pull requests

jobs:
check:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

# Note: Actually we don't need Maven CLI, only Java 17, but this may have additional benefits due to the Maven cache
- name: Setup Maven
uses: s4u/setup-maven-action@4fdbe2a6a718a03bf4874636eed4311886cab6ba # v1.5.1
with:
java-version: 17
java-distribution: temurin
maven-version: 3.8.6

- name: Clean
run: ./build.sh clean
working-directory: ./build

- name: Test (commitStage)
run: ./build.sh commitStage
# run: ./build.sh integrationStage
working-directory: ./build

# https://github.com/marketplace/actions/junit-report-action
- name: Publish Test Report
uses: mikepenz/action-junit-report@9379f0ccddcab154835d4e2487555ee79614fe95 # v4.2.1
if: always() # always run even if the previous step fails
with:
report_paths: 'build/target/testReports/*.xml'

# TODO allure report?
# build/target/allure-results

# TODO archive logs?
# build/target/testReports/*.out,build/target/testReports/*.err
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Maven
uses: s4u/setup-maven-action@v1.5.1
with:
java-version: 17
java-distribution: temurin
maven-version: 3.8.6

- name: Clean
run: ./build.sh clean
working-directory: ./build

- name: Test
run: ./build.sh commitStage
working-directory: ./build

- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: always() # always run even if the previous step fails
with:
# fail if there are no test results
require_tests: true

# Workaround for check that is additionally created being associated
# to the wrong workflow/run. Instead no additional check is created.
# See https://github.com/mikepenz/action-junit-report/issues/40
annotate_only: true
detailed_summary: true
report_paths: 'build/target/testReports/*.xml'
83 changes: 83 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Master Branch Workflow

on:
push:
branches:
#- master # Trigger on pushes to the master branch
- build/ING-4164
workflow_dispatch: {}

jobs:
build:
runs-on: ubuntu-latest

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

- name: Setup Maven
uses: s4u/setup-maven-action@v1.5.1
with:
java-version: 17
java-distribution: temurin
maven-version: 3.8.6

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}

- name: Clean
run: ./build.sh clean
working-directory: ./build

- name: Create hale-docker.conf file
run: |
mkdir -p ~/.hale
cat <<EOF > ~/.hale/hale-docker.conf
global {
dockerHost="unix:///var/run/docker.sock"
}
EOF
- name: Test
run: ./build.sh integrationStage
working-directory: ./build

- name: Product
run: ./build.sh product --arch x86_64 --os linux HALE
./build.sh product --arch x86_64 --os windows HALE
./build.sh product --arch x86_64 --os macosx HALE
./build.sh product --arch x86_64 --os linux --publish Infocenter
working-directory: ./build

- name: Install AWS CLI
uses: unfor19/install-aws-cli-action@v1
with:
version: 1

- name: Update site
env:
AWS_ACCESS_KEY_ID: ${{ secrets.BUILD_ARCHIVE_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.BUILD_ARCHIVE_SECRET_KEY }}
run: ./upload-site.sh
working-directory: ./build

- name: Deploy Artifacts
run: ./build.sh deployArtifacts
working-directory: ./build

- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: always() # always run even if the previous step fails
with:
# fail if there are no test results
require_tests: true

# Workaround for check that is additionally created being associated
# to the wrong workflow/run. Instead no additional check is created.
# See https://github.com/mikepenz/action-junit-report/issues/40
annotate_only: true
detailed_summary: true
report_paths: 'build/target/testReports/*.xml'
80 changes: 80 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Release Branch Workflow

on:
push:
branches:
- release/* # Trigger on pushes to the master branch
workflow_dispatch: {}

jobs:
build:
runs-on: ubuntu-latest

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

- name: Setup Maven
uses: s4u/setup-maven-action@v1.5.1
with:
java-version: 17
java-distribution: temurin
maven-version: 3.8.6

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}

- name: Clean
run: ./build.sh clean
working-directory: ./build


- name: Create hale-docker.conf file
run: |
mkdir -p ~/.hale
cat <<EOF > ~/.hale/hale-docker.conf
global {
dockerHost="unix:///var/run/docker.sock"
}
EOF
- name: Test
run: ./build.sh integrationStage
working-directory: ./build

- name: Product
run: ./build.sh product --arch x86_64 --os linux HALE
./build.sh product --arch x86_64 --os windows HALE
./build.sh product --arch x86_64 --os macosx HALE
./build.sh product --arch x86_64 --os linux --publish Infocenter
working-directory: ./build

- name: Install AWS CLI
uses: unfor19/install-aws-cli-action@v1
with:
version: 1

- name: Update site
run: ./upload-site.sh
working-directory: ./build

- name: Deploy Artifacts
run: ./build.sh deployArtifacts
working-directory: ./build

- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: always() # always run even if the previous step fails
with:
# fail if there are no test results
require_tests: true

# Workaround for check that is additionally created being associated
# to the wrong workflow/run. Instead no additional check is created.
# See https://github.com/mikepenz/action-junit-report/issues/40
annotate_only: true
detailed_summary: true
report_paths: 'build/target/testReports/*.xml'
5 changes: 4 additions & 1 deletion build/gradle/commitAndProductionStage.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -1033,10 +1033,13 @@ task buildProduct(dependsOn: createProductFeature) {
doFirst{
def projectRoot = project.ext.rootDir.path
System.setProperty( MavenCli.MULTIMODULE_PROJECT_DIRECTORY, projectRoot);

// attempt to work around issue on GitHub Actions where downloading dependencies with Maven fails
System.setProperty( 'maven.wagon.httpconnectionManager.ttlSeconds', '120' )
}
doLast {
def projectRoot = project.ext.rootDir.path
def res = new MavenCli().doMain([ '-e', 'package' ] as String[], project.ext.rootDir.path , System.out, System.err)
def res = new MavenCli().doMain([ '-e', 'package'] as String[], project.ext.rootDir.path , System.out, System.err)
if (res != 0) {
throw new RuntimeException("Maven failed with exit code ${res}")
}
Expand Down
4 changes: 4 additions & 0 deletions build/gradle/updateSite.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ task buildUpdateSite(dependsOn: [ createUpdateSiteFeature, generatePomFiles ]) {
pg.generateParentPomFile(parentPomConfig)

System.setProperty( MavenCli.MULTIMODULE_PROJECT_DIRECTORY, project.ext.rootDir.path);

// attempt to work around issue on GitHub Actions where downloading dependencies with Maven fails
System.setProperty( 'maven.wagon.httpconnectionManager.ttlSeconds', '120' )

// build update site
def res = new MavenCli().doMain([ 'package' ] as String[], project.ext.rootDir.path, System.out, System.err)
if (res != 0) {
Expand Down

0 comments on commit 8a6ca3c

Please sign in to comment.