Skip to content

Keep exception in case of error #98

Keep exception in case of error

Keep exception in case of error #98

Workflow file for this run

# This file was automatically generated by sbt-github-actions using the
# githubWorkflowGenerate task. You should add and commit this file to
# your git repository. It goes without saying that you shouldn't edit
# this file by hand! Instead, if you wish to make changes, you should
# change your sbt build configuration to revise the workflow description
# to meet your needs, then regenerate this file.
name: Continuous Integration
on:
pull_request:
branches: [master, main, backport/v*]
types: [opened, reopened, synchronize, ready_for_review]
push:
branches: [master, main, backport/v*]
env:
SBT: sbt
REPO_SLUG: ${{ github.repository }}
ENCRYPTION_PASSWORD: ${{ secrets.ENCRYPTION_PASSWORD }}
GITHUB_ACTOR: precog-bot
GITHUB_TOKEN: ${{ secrets.PRECOG_GITHUB_TOKEN }}
jobs:
build:
name: Build and Test
if: '!(github.event_name == ''pull_request'' && github.event.pull_request.draft)'
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.16]
java: [temurin@17]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Java (temurin@17)
if: matrix.java == 'temurin@17'
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
cache: sbt
- name: Setup sbt
uses: sbt/setup-sbt@v1
- name: Common sbt setup
if: env.ENCRYPTION_PASSWORD != null
run: $SBT '++ ${{ matrix.scala }}' transferCommonResources
- name: Fetch base
if: github.event_name == 'pull_request'
run: git fetch origin ${{github.event.pull_request.base.ref}}
- name: Get current version
id: current_version
if: github.event_name == 'pull_request'
run: echo 'CURRENT_VERSION='$(cat version.sbt | grep version | awk '{ gsub(/"/, "", $5); print $5 }') >> $GITHUB_OUTPUT
- name: Get version on target
id: target_version
if: github.event_name == 'pull_request'
run: 'echo ''TARGET_VERSION=''$(git show origin/${{github.event.pull_request.base.ref}}:version.sbt | grep version | awk ''{ gsub(/"/, "", $5); print $5 }'') >> $GITHUB_OUTPUT'
- name: Compare versions
id: compare_versions
if: github.event_name == 'pull_request'
uses: actions/github-script@v6
with:
script: |
const versionToBump = '${{steps.target_version.outputs.TARGET_VERSION}}'
const parsedVersion = versionToBump.split(".")
var major = Number(parsedVersion[0])
var minor = Number(parsedVersion[1])
var patch = Number(parsedVersion[2])
const prResponse = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: ${{github.event.pull_request.number}}
})
const pr = prResponse.data
if (pr === undefined || prResponse.status !== 200) {
throw new Error("Could not fetch PR with number " + ${{github.event.pull_request.number}} + ": " + prResponse.status)
}
for (const label of pr.labels) {
if (label.name === 'version: revision') {
patch = patch + 1
break
} else if (label.name === 'version: feature') {
patch = 0
minor = minor + 1
break
} else if (label.name === 'version: breaking') {
major = major + 1
minor = 0
patch = 0
break
} else if (label.name === 'version: release') {
major = major + 1
minor = 0
patch = 0
break
}
}
const bumpedVersion = major + '.' + minor + '.' + patch
const currentVersion = '${{steps.current_version.outputs.CURRENT_VERSION}}'
if (bumpedVersion === versionToBump) {
throw new Error("Could not detect the version label on PR " + pr.number)
}
if (bumpedVersion !== currentVersion) {
console.log("Detected that bump is required to: " + bumpedVersion)
return {
nextVersion: bumpedVersion
}
} else {
console.log("No bump is required")
return { nextVersion: "" }
}
- name: Ensure version does not need bumping
if: github.event_name == 'pull_request'
run: '[ "${{fromJson(steps.compare_versions.outputs.result).nextVersion}}" = "" ]'
- name: Check that workflows are up to date
run: $SBT '++ ${{ matrix.scala }}' githubWorkflowCheck
- run: $SBT '++ ${{ matrix.scala }}' ci
- name: Compress target directories
run: tar cf targets.tar target core/target project/target
- name: Upload target directories
uses: actions/upload-artifact@v4
with:
name: target-${{ matrix.os }}-${{ matrix.scala }}-${{ matrix.java }}
path: targets.tar
publish:
name: Publish Artifacts
needs: [build]
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/backport/v') || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.16]
java: [temurin@17]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Java (temurin@17)
if: matrix.java == 'temurin@17'
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
cache: sbt
- name: Setup sbt
uses: sbt/setup-sbt@v1
- name: Download target directories (2.13.16)
uses: actions/download-artifact@v4
with:
name: target-${{ matrix.os }}-2.13.16-${{ matrix.java }}
- name: Inflate target directories (2.13.16)
run: |
tar xf targets.tar
rm targets.tar
- name: Common sbt setup
run: $SBT transferCommonResources transferPublishAndTagResources
- run: ./scripts/commonSetup
- name: Publish artifacts and create tag
run: ./scripts/publishAndTag ${{ github.repository }}
- run: $SBT dependencyUpdates
bump_version:
name: Bump Version
needs: [check-labels]
if: github.event_name == 'pull_request' && !github.event.pull_request.draft && (github.event.pull_request.base.ref == 'main' || startsWith(github.event.pull_request.base.ref, 'backport/v') || github.event.pull_request.base.ref == 'main' || github.event.pull_request.base.ref == 'master')
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.10]
java: [zulu@8]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (fast)
uses: actions/checkout@v3
with:
token: ${{ secrets.PRECOG_GITHUB_TOKEN }}
- name: Fetch base
if: github.event_name == 'pull_request'
run: git fetch origin ${{github.event.pull_request.base.ref}}
- name: Get current version
id: current_version
if: github.event_name == 'pull_request'
run: echo 'CURRENT_VERSION='$(cat version.sbt | grep version | awk '{ gsub(/"/, "", $5); print $5 }') >> $GITHUB_OUTPUT
- name: Get version on target
id: target_version
if: github.event_name == 'pull_request'
run: 'echo ''TARGET_VERSION=''$(git show origin/${{github.event.pull_request.base.ref}}:version.sbt | grep version | awk ''{ gsub(/"/, "", $5); print $5 }'') >> $GITHUB_OUTPUT'
- name: Compare versions
id: compare_versions
if: github.event_name == 'pull_request'
uses: actions/github-script@v6
with:
script: |
const versionToBump = '${{steps.target_version.outputs.TARGET_VERSION}}'
const parsedVersion = versionToBump.split(".")
var major = Number(parsedVersion[0])
var minor = Number(parsedVersion[1])
var patch = Number(parsedVersion[2])
const prResponse = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: ${{github.event.pull_request.number}}
})
const pr = prResponse.data
if (pr === undefined || prResponse.status !== 200) {
throw new Error("Could not fetch PR with number " + ${{github.event.pull_request.number}} + ": " + prResponse.status)
}
for (const label of pr.labels) {
if (label.name === 'version: revision') {
patch = patch + 1
break
} else if (label.name === 'version: feature') {
patch = 0
minor = minor + 1
break
} else if (label.name === 'version: breaking') {
major = major + 1
minor = 0
patch = 0
break
} else if (label.name === 'version: release') {
major = major + 1
minor = 0
patch = 0
break
}
}
const bumpedVersion = major + '.' + minor + '.' + patch
const currentVersion = '${{steps.current_version.outputs.CURRENT_VERSION}}'
if (bumpedVersion === versionToBump) {
throw new Error("Could not detect the version label on PR " + pr.number)
}
if (bumpedVersion !== currentVersion) {
console.log("Detected that bump is required to: " + bumpedVersion)
return {
nextVersion: bumpedVersion
}
} else {
console.log("No bump is required")
return { nextVersion: "" }
}
- name: Modify version
id: modify_version
if: fromJson(steps.compare_versions.outputs.result).nextVersion != ''
run: |
printf '// Last bumped by PR ${{github.event.pull_request.number}}
ThisBuild / version := "${{fromJson(steps.compare_versions.outputs.result).nextVersion}}"
' > version.sbt
- name: Commit changes
if: fromJson(steps.compare_versions.outputs.result).nextVersion != ''
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: 'Version bump: ${{fromJson(steps.compare_versions.outputs.result).nextVersion}}'
commit_user_name: precog-bot
commit_user_email: bot@precog.com
auto-merge:
name: Auto Merge
needs: [build, bump_version]
if: 'github.event_name == ''pull_request'' && contains(github.head_ref, ''version-bump'') && contains(github.event.pull_request.labels.*.name, ''version: revision'') && github.event.pull_request.user.login == ''precog-bot'''
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.10]
java: [zulu@8]
runs-on: ${{ matrix.os }}
steps:
- name: Merge
id: merge
uses: actions/github-script@v6
with:
script: |
github.rest.pulls.merge({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: ${{ github.event.pull_request.number }},
});
github-token: ${{ secrets.PRECOG_GITHUB_TOKEN }}
check-labels:
name: Check Labels
if: github.event_name == 'pull_request' && !github.event.pull_request.draft
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.10]
java: [zulu@8]
runs-on: ${{ matrix.os }}
steps:
- name: Check PR labels
uses: docker://agilepathway/pull-request-label-checker:v1.4.30
with:
one_of: 'version: breaking,version: feature,version: revision,version: release'
none_of: ':stop_sign:'
repo_token: ${{ env.GITHUB_TOKEN }}