Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI improvements #148

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 54 additions & 27 deletions .github/actions/build-project/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ inputs:
elastic-password:
description: "Secret with auth token to elasticsearch"
required: true
workflow-name:
description: "Name of the calling workflow, used to resolve build URL. Leave empty to use default (execute-build-plan / {{github.job}} (<project-name>))"
default: ""
runs:
using: "composite"
steps:
- uses: coursier/cache-action@v6.4
- uses: coursier/setup-action@v1
with:
apps: cs
Expand All @@ -39,7 +43,6 @@ runs:
echo "java-version=$javaVersion" >> $GITHUB_ENV
echo "JavaVersion set to $javaVersion"


- name: Check can skip build
id: check-history
shell: bash
Expand Down Expand Up @@ -73,20 +76,64 @@ runs:
echo "Can skip build: $canSkip"
echo "can-skip-build=${canSkip}" >> $GITHUB_OUTPUT

- name: Build project
uses: addnab/docker-run-action@v3
if: steps.check-history.outputs.can-skip-build != 'true'
with:
image: "virtuslab/scala-community-build-project-builder:jdk${{ env.java-version }}-v0.2.3"
options: -v ${{ github.workspace }}:/opencb/
run: |
DefaultConfig='{"memoryRequestMb":4096}'
ConfigFile="/opencb/.github/workflows/buildConfig.json"
config () {
path=".\"${{ inputs.project-name }}\"$@"
jq -c -r "$path" $ConfigFile
}

touch build-logs.txt build-summary.txt
# Assume failure unless overwritten by a successful build
echo 'failure' > build-status.txt

/build/build-revision.sh \
"$(config .repoUrl)" \
"$(config .revision)" \
"${{ inputs.scala-version }}" \
"$(config .version)" \
"$(config .targets)" \
"${{ inputs.maven-repo-url }}" \
'1.6.2' \
"$(config .config // ${DefaultConfig})" \
"${{ inputs.extra-scalac-options }}" \
"${{ inputs.disabled-scalac-options }}" 2>&1 | tee build-logs.txt

# Store results
mv build-logs.txt /opencb/
mv build-status.txt /opencb/
mv build-summary.txt /opencb/

- name: Check status status
id: check-status
shell: bash
if: steps.check-history.outputs.can-skip-build != 'true'
run: echo "status=$(cat build-status.txt)" >> $GITHUB_OUTPUT

- name: Get current job URL
id: job-info
if: steps.check-history.outputs.can-skip-build != 'true'
if: steps.check-status.outputs.status != 'success'
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
GITHUB_API="repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs"
JOB_NAME="execute-build-plan / ${{ github.job }} (${{ inputs.project-name }})"
if [[ "${{ inputs.workflow-name }}" != "" ]]; then
JOB_NAME="${{ inputs.workflow-name }}"
fi
PARAMS="?per_page=100"
SELECT_URL=".jobs | map(select(.name == \"${JOB_NAME}\")) | .[0].html_url"

set -o pipefail

outFile="gh.out"
buildURL=""
for i in $(seq 1 10) ;do
Expand All @@ -105,39 +152,24 @@ runs:
break
fi
done

echo "Build URL: $buildURL"
echo "build-url=${buildURL}" >> $GITHUB_OUTPUT

- name: Build project
- name: Index results
uses: addnab/docker-run-action@v3
if: steps.check-history.outputs.can-skip-build != 'true'
with:
image: "virtuslab/scala-community-build-project-builder:jdk${{ env.java-version }}-v0.2.3"
options: -v ${{ github.workspace }}:/opencb/ -e ELASTIC_USERNAME=${{ inputs.elastic-user }} -e ELASTIC_PASSWORD=${{ inputs.elastic-password }}
run: |
ConfigFile="/opencb/.github/workflows/buildConfig.json"
DefaultConfig='{"memoryRequestMb":4096}'
config () {
path=".\"${{ inputs.project-name }}\"$@"
jq -c -r "$path" $ConfigFile
}

touch build-logs.txt build-summary.txt
# Assume failure unless overwritten by a successful build
echo 'failure' > build-status.txt

/build/build-revision.sh \
"$(config .repoUrl)" \
"$(config .revision)" \
"${{ inputs.scala-version }}" \
"$(config .version)" \
"$(config .targets)" \
"${{ inputs.maven-repo-url }}" \
'1.6.2' \
"$(config .config // ${DefaultConfig})" \
"${{ inputs.extra-scalac-options }}" \
"${{ inputs.disabled-scalac-options }}" 2>&1 | tee build-logs.txt
cd /opencb/

# Remove ASCII coloring from the indexed logs
cat build-logs.txt | sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2};?)?)?[mGK]//g" > build-logs-uncolored.txt
Expand All @@ -156,18 +188,13 @@ runs:
if [ $? != 0 ]; then
echo "::warning title=Indexing failure::Indexing results of ${{ inputs.project-name }} failed"
fi

# Store results
mv build-logs.txt /opencb/
mv build-status.txt /opencb/
mv build-summary.txt /opencb

- name: Check results
shell: bash
if: steps.check-history.outputs.can-skip-build != 'true'
run: |
# Set the result of the build
if [[ "$(cat build-status.txt)" == "success" ]]; then
if [[ "${{ steps.check-status.outputs.status }}" == "success" ]]; then
echo "Build successful"
else
echo "Build failure! Check logs for details"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/buildSingle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,4 @@ jobs:
maven-repo-url: ${{ needs.setup-build.outputs.maven-repo-url }}
elastic-user: ${{ secrets.OPENCB_ELASTIC_USER }}
elastic-password: ${{ secrets.OPENCB_ELASTIC_PSWD }}
workflow-name: "build-project"
1 change: 1 addition & 0 deletions .github/workflows/compare.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
steps:
- name: Git Checkout
uses: actions/checkout@v3
- uses: coursier/cache-action@v6.4
- name: Install coursier
uses: coursier/setup-action@v1
with:
Expand Down
6 changes: 3 additions & 3 deletions k8s/project-builder-sbt-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ spec:
- |
(/build/build-revision.sh \
https://github.com/typelevel/shapeless-3.git \
"v3.0.4" \
3.1.0 \
"v3.3.0" \
3.2.2 \
"" \
"org.typelevel%shapeless3-deriving org.typelevel%shapeless3-test org.typelevel%shapeless3-typeable dummy.org%dummy-project" \
https://mvn-repo:8081/maven2/test \
1.5.5 \
1.8.0 \
'{"sbt": {"commands": ["show crossScalaVersions", "show scalaVersion", "show scalacOptions"] }, "projects": {"exclude": ["dummy.org%dummy-.*"], "overrides": {"shapeless3-deriving": {"tests": "compile-only"}, "shapeless3-typeable": {"tests": "disabled"}} } }' \
"" \
"" \
Expand Down
4 changes: 2 additions & 2 deletions project-builder/sbt/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ function runSbt() {
tq='"""'
sbt ${sbtSettings[@]} \
"setCrossScalaVersions $scalaVersion" \
"$setScalaVersionCmd -v" \
"removeScalacOptions -deprecation -feature -Xfatal-warnings -Werror ${disabledScalacOption}" \
"appendScalacOptions ${extraScalacOptions}" \
"$setScalaVersionCmd -v" \
"set every credentials := Nil" \
"$customCommands" \
"$setVersionCmd" \
"$enableMigrationModeCmd $sourceVersionToUseForMigration" \
"$customCommands" \
"moduleMappings" \
"runBuild ${scalaVersion} ${tq}${projectConfig}${tq} $targetsString" | tee $logFile
}
Expand Down