Build and test Everest #423
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: Build and test Everest | |
on: | |
push: | |
branches-ignore: | |
- _** | |
pull_request: | |
workflow_dispatch: | |
inputs: | |
ocaml_version: | |
type: string | |
description: OCaml version | |
required: true | |
default: 5.2.1 | |
ubuntu_version: | |
type: choice | |
description: Ubuntu version | |
required: true | |
default: 24.04 | |
options: | |
- 24.04 | |
- 22.04 | |
- 20.04 | |
jobs: | |
build: | |
runs-on: [self-hosted, linux, X64] | |
steps: | |
- name: Record initial timestamp | |
run: | | |
echo "CI_INITIAL_TIMESTAMP=$(date '+%s')" >> $GITHUB_ENV | |
- name: Check out repo | |
uses: actions/checkout@v3 | |
- name: Identify the notification channel | |
run: | | |
echo "CI_SLACK_CHANNEL=$(jq -c -r '.NotificationChannel' .docker/build/config.json)" >> $GITHUB_ENV | |
- name: Set the Ubuntu version | |
if: ${{ (github.event_name == 'workflow_dispatch') }} | |
run: | | |
echo "CI_UBUNTU_VERSION=--build-arg UBUNTU_VERSION=$CI_UBUNTU_VER" >> $GITHUB_ENV | |
echo "CI_OCAML_VERSION=--build-arg OCAML_VERSION=$CI_OCAML_VER" >> $GITHUB_ENV | |
env: | |
CI_UBUNTU_VER: ${{ inputs.ubuntu_version }} | |
CI_OCAML_VER: ${{ inputs.ocaml_version }} | |
- name: Build Everest and its dependencies | |
run: | | |
ci_docker_image_tag=everest:local-run-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT | |
ci_docker_builder=builder_everest_${GITHUB_RUN_ID}_${GITHUB_RUN_ATTEMPT} | |
docker buildx create --name $ci_docker_builder --driver-opt env.BUILDKIT_STEP_LOG_MAX_SIZE=500000000 | |
if docker buildx build --pull --builder $ci_docker_builder --load -t $ci_docker_image_tag -f .docker/build/linux/Dockerfile.Ubuntu $CI_UBUNTU_VERSION $CI_OCAML_VERSION . ; then | |
ci_docker_status=true | |
else | |
ci_docker_status=false | |
fi | |
if $ci_docker_status ; then | |
if ! { echo $GITHUB_REF_NAME | grep '/' ; } ; then | |
docker tag $ci_docker_image_tag everest:local-branch-$GITHUB_REF_NAME | |
fi | |
docker tag $ci_docker_image_tag everest:local-commit-$GITHUB_SHA | |
fi | |
docker buildx rm $ci_docker_builder | |
$ci_docker_status | |
- name: Compute elapsed time | |
if: ${{ always() }} | |
run: | | |
CI_FINAL_TIMESTAMP=$(date '+%s') | |
CI_TIME_DIFF=$(( $CI_FINAL_TIMESTAMP - $CI_INITIAL_TIMESTAMP )) | |
echo "CI_TIME_DIFF_S=$(( $CI_TIME_DIFF % 60 ))" >> $GITHUB_ENV | |
echo "CI_TIME_DIFF_M=$(( ($CI_TIME_DIFF / 60) % 60 ))" >> $GITHUB_ENV | |
echo "CI_TIME_DIFF_H=$(( $CI_TIME_DIFF / 3600 ))" >> $GITHUB_ENV | |
case ${{ job.status }} in | |
(success) | |
echo "CI_EMOJI=✅" >> $GITHUB_ENV | |
;; | |
(cancelled) | |
echo "CI_EMOJI=⚠" >> $GITHUB_ENV | |
;; | |
(*) | |
echo "CI_EMOJI=❌" >> $GITHUB_ENV | |
;; | |
esac | |
echo "CI_COMMIT=$(echo ${{ github.event.head_commit.id || github.event.pull_request.head.sha }} | grep -o '^........')" >> $GITHUB_ENV | |
- name: Check if we should post to Slack | |
if: ${{ always() }} | |
run: | |
echo "SLACK_SHOULD_POST=$SLACK_SHOULD_POST" >> $GITHUB_ENV | |
env: | |
SLACK_SHOULD_POST: ${{ secrets.SLACK_WEBHOOK_URL != '' && 'yes' || 'no' }} | |
# ^ this thing is the closest to a ternary operator in github actions | |
- name: Post to the Slack channel | |
if: ${{ always () && env.SLACK_SHOULD_POST == 'yes' }} | |
id: slack | |
uses: slackapi/[email protected] | |
with: | |
channel-id: ${{ env.CI_SLACK_CHANNEL }} | |
payload: | | |
{ | |
"blocks" : [ | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": "<${{ github.event.head_commit.url || github.event.pull_request.html_url }}|${{ env.CI_COMMIT }}> on (${{ github.ref_name }}) by ${{ github.event.head_commit.author.username || github.event.pull_request.user.login }}" | |
} | |
}, | |
{ | |
"type": "section", | |
"text": { | |
"type": "plain_text", | |
"text": ${{ toJSON(github.event.head_commit.message || github.event.pull_request.title) }} | |
} | |
}, | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": "${{ env.CI_EMOJI }} <https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}|${{ job.status }}>" | |
} | |
}, | |
{ | |
"type": "section", | |
"text": { | |
"type": "plain_text", | |
"text": "Duration: ${{ env.CI_TIME_DIFF_H }}h ${{ env.CI_TIME_DIFF_M }}min ${{ env.CI_TIME_DIFF_S }}s" | |
} | |
} | |
] | |
} | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK |