Skip to content

Commit

Permalink
Merge branch 'github_action_mac'
Browse files Browse the repository at this point in the history
  • Loading branch information
j-woz committed Dec 6, 2024
2 parents d7ee12f + c725c86 commit 78ea0ca
Show file tree
Hide file tree
Showing 19 changed files with 696 additions and 43 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Build and Test 🧪

on:
# Schedule and workflow_dispatch (manual) only work on default branch
schedule:
- cron: "0 6 * * *" # Fire at 06:00 AM every day
workflow_dispatch:
pull_request:
push:
branches:
- github_action_mac
# - github_action_build # The name of our test branch
# - master
release:
types:
- published

permissions:
contents: read # To read the project source code (git)
# packages: read # To read the docker image from package registry

jobs:
build_swift-t:
name: Swift/T OS=${{ matrix.os }} PY=${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
# - macos-14

# Comma separated list of python versions to test
python-version: ["3.11"] # "3.8", "3.9", "3.10",

mpi:
- mpich

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

# R may need to run before installing sed:
- name: Set up R
uses: r-lib/actions/setup-r@v2

- name: Install deps
run: |
dev/github-actions/setup-deps.sh ${{ matrix.os }}
# # TODO RInside
- name: Install R requirements
run: R -e "install.packages('RInside')"
# # run: Rscript install/R-requirements.R

# - uses: r-lib/actions/setup-r-dependencies@v2
# with:
# extra-packages: any::RInside


- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

# - name: Upgrade pip
# run: python -m pip install -U pip

- name: Initialize swift-t settings
run: |
dev/build/init-settings.sh
dev/github-actions/edit-settings.sh
# TODO set swift-t install, R, python, and ??
# sed -i 's/original/new/g' file.txt
# - run:
# - run: sed -i 's/ENABLE_R=0/ENABLE_R=1/g' dev/build/swift-t-settings.sh

- name: build swift-t
run: |
dev/build/build-swift-t.sh -vv
- name: Report Swift/T version info
run: /tmp/swift-t-install/stc/bin/swift-t -v

- name: Check that Swift/T runs
run: /tmp/swift-t-install/stc/bin/swift-t -E 'trace(42);'
80 changes: 80 additions & 0 deletions .github/workflows/conda.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Conda Build 🐍

# Build the Swift/T Anaconda package

env:
# For Chicago time on log messages:
TZ: CST6CDT

on:
# Schedule and workflow_dispatch (manual) only work on default branch
schedule:
- cron: "0 6 * * *" # Fire at 06:00 AM every day
workflow_dispatch:
pull_request:
push:
branches:
- github_action_mac
# - master
release:
types:
- published

permissions:
contents: read # To read the project source code (git)

jobs:
build_conda_pkg:
name: OS=${{ matrix.os }} PY=${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
# - ubuntu-latest
- macos-13
# - macos-14 # This is ARM64
# - macos-14-arm64

# Comma separated list of python versions to test
python-version: ["3.11"] # "3.9",

mpi:
- mpich

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

- name: Setup dependencies
run: |
dev/github-actions/check setup-conda.sh ${{ matrix.os }}
- name: Save tool.log
uses: actions/upload-artifact@v4
with:
name: tool-log
path: tool.log

- name: Check tool.log
run: |
grep "setup-conda: SUCCESS" tool.log
- name: Build Anaconda package
run: |
dev/github-actions/check dev/jenkins/anaconda.sh
- name: Save anaconda.log
uses: actions/upload-artifact@v4
with:
name: anaconda-log
path: anaconda.log

- name: Check anaconda.log
run: |
grep "anaconda.sh: SUCCESS" tool.log
- name: Report Swift/T version info
run: /tmp/swift-t-install/stc/bin/swift-t -v

- name: Check that Swift/T runs
run: /tmp/swift-t-install/stc/bin/swift-t -E 'trace(42);'
11 changes: 10 additions & 1 deletion dev/build/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ assert()
}

LOG()
# Usage: LOG $LVL MESSAGE...
{
if (( ${#} == 0 ))
then
Expand Down Expand Up @@ -125,6 +126,11 @@ check_make()
MAKE_QUIET="--quiet"
fi

if (( VERBOSITY >= $LOG_DEBUG ))
then
echo "using make: " $( which make )
fi

MAKE_V=""
if (( VERBOSITY == $LOG_TRACE ))
then
Expand All @@ -136,9 +142,12 @@ make_clean()
{
if (( RUN_MAKE_CLEAN ))
then
if [ -f Makefile ]
if [[ -f Makefile ]]
then
LOG $LOG_DEBUG "make_clean() ..."
make clean
else
LOG $LOG_DEBUG "make_clean(): No Makefile."
fi
fi
}
Expand Down
10 changes: 6 additions & 4 deletions dev/conda/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ toc::[]
We are Anaconda project `swift-t`: +
https://anaconda.org/swift-t

`swift-t`:: Swift/T
`swift-t-r`:: Swift/T and R
`swift-t`::
Swift/T

`swift-t-r`::
Swift/T and R

== End user interface

Expand All @@ -39,7 +42,6 @@ These are standard directory names:
* `linux-64`: "Linux on PC": Works
* `osx-64`: "Mac on PC": Works
* `osx-arm64`: "Mac on ARM": Works
+
This plaform skips Ant, the C compiler, and ZSH, and assumes they are on the user system:
* `aarch64`: "Linux on ARM": Works

Expand Down Expand Up @@ -145,7 +147,7 @@ Use `dev/conda/upload.sh` to automate this.
== Dependencies

`r-rinside`::
This package does not exist for `linux-aarch-64` +
This package does not exist for `linux-aarch-64`

== M4 usage

Expand Down
8 changes: 7 additions & 1 deletion dev/conda/build-generic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,11 @@ then
done
fi

if [[ $PLATFORM =~ osx-* ]]
set -x
if [[ $PLATFORM =~ osx-* ]] && [[ ${GITHUB_ACTION:-0} != 0 ]]
then
# Use this syntax on Mac, unless in GitHub,
# where we install Homebrew gnu-sed
SED_I=( sed -i "''" )
else
SED_I=( sed -i )
Expand Down Expand Up @@ -162,4 +165,7 @@ for file in turbine-config.sh; do
ln -sv ../swift-t/turbine/scripts/$file .
done

set -x
ls $PREFIX/bin

echo "BUILD-GENERIC.SH STOP $( date '+%Y-%m-%d %H:%M:%S' )"
1 change: 1 addition & 0 deletions dev/conda/conda-platform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
set -eu

# CONDA PLATFORM
# Build conda for a given PLATFORM
# Dependency files are in the PLATFORM directory
# Generated scripts and log files are put in the PLATFORM directory
# Arguments:
Expand Down
6 changes: 1 addition & 5 deletions dev/conda/helpers.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,11 @@

checksum()
{
# Use redirection to suppress filename in md5 output
# Use redirection to suppress filename in program output
local PKG=$1
if [[ $PLATFORM =~ osx-* ]] {
md5 -r < $PKG
} else {
md5sum < $PKG
}
}

print_environment()
{
}
51 changes: 38 additions & 13 deletions dev/conda/osx-64/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,48 @@ DEV_CONDA=$( cd $RECIPE_DIR/.. ; /bin/pwd -P )
(
set -eu

# Find Java bin directory
echo CONDA_EXE=$CONDA_EXE
CONDA=$( dirname $( dirname $CONDA_EXE ) )
# OpenJDK home should be under MINICONDA/pkgs/openjdk-*
OPENJDK=( $( find $CONDA/pkgs -type d -name "openjdk-*" ) )
if (( ${#OPENJDK} == 0 ))
# Find Java bin directory in Conda PREFIX sandbox
# echo CONDA_EXE=$CONDA_EXE
# CONDA=$( dirname $( dirname $CONDA_EXE ) )
# OpenJDK home should be under PREFIX/pkgs/openjdk-*
# Should be in PREFIX/bin but is not on any system
# On Linux it is under $PREFIX/pkgs/openjdk-*/lib/jvm/bin
# On GitHub macos-13 it is under $PREFIX/lib/jvm/bin
echo FIND JAVA PREFIX $PREFIX
which java javac || true
conda list
# Does not exist:
# source $PREFIX/etc/profile.d/conda.sh
set -x
find $PREFIX
which java javac || true
echo $PATH
set -x
FOUND_JDK=0
find $PREFIX -name java
JDKS=( $( find $PREFIX/pkgs -type d -name "openjdk-*" ) )
if (( ${#JDKS} > 0 ))
then
echo "build.sh: Could not find OpenJDK in $CONDA"
exit 1
JDK_BIN=${JDKS[0]}/lib/jvm/bin
if ! [[ -d $JDK_BIN ]]
then
echo "build.sh: Broken JVM directory structure in $PREFIX"
exit 1
fi
FOUND_JDK=1
fi
if ! [[ -d ${OPENJDK[0]}/lib/jvm/bin ]]
if [[ -d $PREFIX/lib/jvm/bin ]]
then
echo "build.sh: Could not find OpenJDK binaries in $CONDA"
JDK_BIN=$PREFIX/lib/jvm/bin
FOUND_JDK=1
fi
if (( ! FOUND_JDK ))
then
echo "build.sh: Could not find OpenJDK in $CONDA"
exit 1
fi
echo "build.sh: Found OpenJDK: $OPENJDK"
PATH=${OPENJDK[0]}/lib/jvm/bin:$PATH
echo "build.sh: Found OpenJDK bin directory: $JDK_BIN"
PATH=$JDK_BIN:$PATH
which java javac

if (( ${ENABLE_R:-0} ))
Expand All @@ -43,6 +68,6 @@ DEV_CONDA=$( cd $RECIPE_DIR/.. ; /bin/pwd -P )

echo "build.sh: calling build-generic.sh ..."
$DEV_CONDA/build-generic.sh
)
) 2>&1 | dd

echo "build.sh: STOP"
24 changes: 24 additions & 0 deletions dev/github-actions/check
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh

# CHECK
# Run job, always return success for GitHub action
# Allows us to capture artifacts and test for success later
# Adds dev/github-actions to PATH to shorten commands

echo "CHECK: ${*}"

if [ ! -d dev/github-actions ]
then
echo "CHECK: MISCONFIGURATION!"
exit 1
fi

PATH=dev/github-actions:$PATH

# Run the arguments here!
if ! ${*}
then
echo "CHECK FAILED: ${*}"
fi

# Always succeeds.
12 changes: 12 additions & 0 deletions dev/github-actions/edit-settings.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh
set -eu

# SETTINGS SH
# Edit swift-t-settings.sh via settings.sed
# Assumes PWD is the top of the Swift/T clone
# We immediately cd into /dev/

cd dev
SETTINGS_SH=build/swift-t-settings.sh
echo "Editing $SETTINGS_SH ..."
sed -i -f github-actions/settings.sed build/swift-t-settings.sh
8 changes: 8 additions & 0 deletions dev/github-actions/settings.sed
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# sed edits to swift-t-settings.sh

s/ENABLE_PYTHON=0/ENABLE_PYTHON=1/
s/MAKE_PARALLELISM=1/MAKE_PARALLELISM=4/

# Local Variables:
# mode: sh;
# End:
Loading

0 comments on commit 78ea0ca

Please sign in to comment.