MacOS Clang #168
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
# | |
# File: %macos-build.yml | |
# | |
#=============================================================================# | |
# | |
# This does MacOS builds on GitHub's Ubuntu container, using clang. | |
# | |
#====# PLEASE READ THE README #===============================================# | |
# | |
# Whenever this file says "See README", that is referring to the notes in the | |
# %.github/workflows/README.md file. If something appears in multiple GitHub | |
# Workflow files, it's best to document it there instead of repeating it: | |
# | |
# https://github.com/metaeducation/ren-c/blob/master/.github/workflows/README.md | |
# | |
name: MacOS Clang | |
# See README: When To Trigger Builds | |
# | |
on: | |
push: | |
branches: [ | |
# master, | |
macos # pushing to macos won't build other workflows, use to debug | |
] | |
pull_request: | |
branches: [ | |
master | |
] | |
workflow_dispatch: # Allows running this workflow manually from Actions tab | |
# Standardize to use bash on all platforms. | |
# | |
# See README: Using The Strict Erroring Bash Shell | |
# | |
defaults: | |
run: | |
shell: bash | |
# Each "Job" runs in its own VM, and a workflow run is made up of one or more | |
# jobs that can run sequentially or in parallel. | |
# | |
# See README: Jobs | |
# | |
jobs: | |
macos-build: # Name of this workflow's only job | |
# https://github.com/actions/virtual-environments#available-environments | |
# | |
runs-on: macos-latest | |
# See README: Build Matrix | |
# | |
strategy: | |
matrix: | |
include: | |
- os-id: 0.2.40 # 64-bit Target (built on this 64-bit platform) | |
config-file: generic.r | |
standard: gnu99 # used for sigjmp_buf (signal safety) | |
debug: none | |
extensions: "UUID *" | |
variation: "" | |
checked: false | |
- os-id: 0.2.40 # 64-bit Target (built on this 64-bit platform) | |
config-file: generic.r | |
standard: gnu99 # used for sigjmp_buf (signal safety) | |
debug: normal | |
extensions: "UUID * ODBC +" | |
variation: "-debug" # !!! Maybe -debug-odbc ? | |
checked: true | |
# MacOS has fully deprecated 32-bit targets...we'll assume that the | |
# Windows/Linux/ARM 32-bit variants cover testing of 32-bit enough. | |
# See README: Environment Variables | |
# | |
env: | |
AWS_S3_BUCKET_NAME: metaeducation | |
# See README: Minimize GitHub-Specific Syntax | |
# | |
OS_ID: ${{ matrix.os-id }} | |
CONFIG_FILE: ${{ matrix.config-file }} | |
STANDARD: ${{ matrix.standard }} | |
DEBUG: ${{ matrix.debug }} | |
EXTENSIONS: ${{ matrix.extensions }} | |
VARIATION: ${{ matrix.variation }} | |
CHECKED: ${{ matrix.checked }} | |
# Steps are a sequence of tasks that will be executed within a single VM | |
# as part of the job. | |
# | |
# See README: Steps | |
# | |
steps: # (no indentatation needed below; so indent the minimum!) | |
#====# CHECKOUT STEPS #=====================================================# | |
# https://github.com/actions/checkout | |
# | |
# See README: Checkout Action | |
# | |
- uses: actions/checkout@v3 # See README: Trusted Actions | |
# The full commit is passed to make to build into the binary, and the | |
# abbreviated commit is used to name the executable. | |
# | |
# See README: Portably Capturing Git Hashes | |
# | |
- name: Grab Git Hash and Short Hash Into Environment Variables | |
run: | | |
git_commit="$(git show --format="%H" --no-patch)" | |
git_commit_short="$(git show --format="%h" --no-patch)" | |
echo "GIT_COMMIT=$git_commit" >> $GITHUB_ENV | |
echo "GIT_COMMIT_SHORT=$git_commit_short" >> $GITHUB_ENV | |
#====# TOOLCHAIN INSTALLATION STEPS #=======================================# | |
- name: Fetch R3 To Use For "Prep" Build Steps as $R3MAKE | |
run: | | |
repo_dir=$(pwd)/ | |
source tools/bash/fetch-prebuilt.sh | |
r3make=$(fetch_prebuilt) | |
echo "R3MAKE is set to $r3make" | |
echo "R3MAKE=$r3make" >> $GITHUB_ENV # pass to next step | |
- name: Stop the build early if the R3MAKE is no good | |
run: | | |
"$R3MAKE" --do "print {R3MAKE is Working} quit" | |
# The ODBC executable is built with debug included, to make the workflow | |
# that uses it for testing ODBC more rigorous. | |
# | |
- name: Get ODBC if Needed | |
if: (env.OS_ID == '0.4.40') && (env.DEBUG == 'normal') | |
run: | | |
# When brew updates automatically, it generates an unsightly amount of | |
# output if it does so during a `brew install`. So redirect the | |
# hundreds of lines to /dev/null to shorten the log. | |
# | |
# https://github.com/Homebrew/legacy-homebrew/issues/35662 | |
# | |
brew update > /dev/null | |
brew install unixodbc | |
# Show a little bit of sanity check information. | |
# | |
- name: Output System Information | |
run: | | |
echo "Clang version check:" | |
clang -v | |
#====# BUILD STEPS #========================================================# | |
# See README: {Braces} For %make.r String Parameters | |
# | |
- name: Use Rebmake to Generate a makefile | |
run: | | |
mkdir build | |
cd build | |
"$R3MAKE" ../make.r \ | |
config="../configs/$CONFIG_FILE" \ | |
target=makefile \ | |
standard=$STANDARD \ | |
os_id=$OS_ID \ | |
debug=$DEBUG \ | |
git_commit="{$GIT_COMMIT}" \ | |
rigorous=no \ | |
static=no \ | |
extensions="$EXTENSIONS" | |
- name: Create Folders For Build Products (Compiler Won't Create Them) | |
run: | | |
cd build | |
make folders | |
- name: Prep the Build By Making Various Auto-Generated .h and .c Files | |
run: | | |
cd build | |
make prep | |
# https://github.com/actions/upload-artifact | |
# | |
- name: Optional Download of Prep Files Before They Can Cause Build Failure | |
if: false # Change this to true to download a file | |
uses: actions/upload-artifact@v2 # See README: Trusted Actions | |
with: | |
name: tmp-internals.h | |
path: build/prep/include/tmp-internals.h | |
- name: Compile and Link the C Files | |
run: | | |
cd build | |
make -j 3 # Mac GitHub Runners have 3 cores, use 3 jobs | |
echo "R3BUILT=$(pwd)/r3" >> $GITHUB_ENV | |
# See README: Ren-C Code As Step | |
# | |
# Note: /usr/local/bin is where you put custom executables, but it's not | |
# in the path on MacOS by default: | |
# | |
# https://dani.gg/en/467-add-usr-local-bin-to-system-path-variable-on-mac-os/ | |
# | |
- name: Copy Built R3 To Where It Can Be Used As A Shell | |
run: | | |
sudo cp build/r3 /usr/local/bin/r3built | |
#====# TESTING STEPS #======================================================# | |
- name: Quick Smoke Test (Print A Message And Quit) | |
run: | | |
"$R3BUILT" --do "print {hi}" | |
- name: HTTPS Read Test (If This Works, A Lot Of Things Are Working) | |
shell: /usr/local/bin/r3built --fragment {0} # README: Ren-C Code As Step | |
run: | | |
print {== Hello From R3 HTTPS Read Test! ==} | |
header: parse as text! read https://example.com [ | |
thru '<h1> accept across to '</h1> | |
] | |
assert [header = "Example Domain"] | |
print ["Succeeded:" header] | |
- name: Test UUID Extension Built As DLL | |
if: false # See https://github.com/metaeducation/ren-c-library/ | |
shell: r3built --fragment {0} # See README: Ren-C Code As Step | |
run: | | |
print {== Hello From R3 DLL Test! ==} | |
mod-uuid: load-extension join what-dir %build/libr3-uuid.dylib | |
print {== UUID Extension Loaded ==} | |
uuid: mod-uuid.generate | |
assert [16 = length of uuid] | |
print ["Succeeded:" uuid] | |
#====# UPLOAD STEP #========================================================# | |
# This action configures the AWS keys stored in GitHub's "Secrets" for | |
# the repository so that `aws s3` allows us to do uploads, without needing | |
# to publish any passwords publicly: | |
# | |
# https://github.com/aws-actions/configure-aws-credentials | |
# | |
# See README: Trusted Actions | |
# | |
- name: Configure AWS Credentials | |
if: github.ref == 'refs/heads/master' # see notes on DEPLOY STEPS | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.METAEDUCATION_AWS_ACCESS_KEY }} | |
aws-secret-access-key: ${{ secrets.METAEDUCATION_AWS_SECRET_KEY }} | |
aws-region: us-east-1 | |
# Name the executable based on the abbreviated commit, whether it is a | |
# debug or release build, and if it was built using C++ or not. Note that | |
# the C++ debug builds have additional runtime checks in the debug | |
# build...though there should not be any impact on the release build. | |
# (Though there may be additional DLL dependencies regardless.) | |
# | |
# !!! All Ren-C stakeholders should be using debug builds at this time. | |
# | |
- name: Deploy Executable | |
if: github.ref == 'refs/heads/master' # see notes on DEPLOY STEPS | |
run: | | |
cd build | |
NEW_NAME="r3-${GIT_COMMIT_SHORT}${VARIATION}" | |
MIME_TYPE="application/x-executable" | |
local=r3 | |
lastpart=travis-builds/${OS_ID}/${NEW_NAME} | |
remote=s3://${AWS_S3_BUCKET_NAME}/$lastpart | |
aws s3 cp $local $remote --content-type $MIME_TYPE | |
echo "R3_URL_LASTPART=$lastpart" >> $GITHUB_ENV | |
#====# BOOTSTRAP STEP #=====================================================# | |
# We should check for bootstrap capability in at least some cases. | |
# Since it slows things down significantly, perhaps only periodically. | |
# (based on random number?) | |
#====# GREENLIGHT STEP #====================================================# | |
- name: Greenlight Build | |
if: github.ref == 'refs/heads/master' # see notes on DEPLOY STEPS | |
run: | | |
cd build | |
local=last-deploy.short-hash | |
# -n option to echo means "no newline at end" (it's not a "text file" | |
# so there is no standard enforcing that it have one...and it's | |
# easier in the client to not have it) | |
# | |
echo -n "${GIT_COMMIT_SHORT}" > $local | |
remote=s3://${AWS_S3_BUCKET_NAME}/travis-builds/${OS_ID}/$local | |
aws s3 cp $local $remote # upload | |
- name: Test That LATEST-OF Script Gives Back The Just-Greenlit Build | |
if: github.ref == 'refs/heads/master' | |
shell: r3built --fragment {0} # See README: Ren-C Code As Step | |
run: | | |
latest-of: do %scripts/latest-of.reb | |
os-id: to tuple! get-env 'OS_ID | |
variation: if "-debug" = get-env 'VARIATION ['debug] else ['release] | |
r3-url-lastpart: get-env 'R3_URL_LASTPART | |
url: latest-of/variant os-id variation | |
parse (as text! url) [thru r3-url-lastpart] then [ | |
print ["LATEST-OF Matched:" url] | |
] else [ | |
fail ["!!! LATEST-OF Gave Mismatched URL:" url] | |
] |