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

Add macOS support #56

Merged
merged 9 commits into from
Dec 26, 2019
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
101 changes: 101 additions & 0 deletions .ci-scripts/release/x86-64-apple-darwin-nightly.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#!/bin/bash

# x86-64-unknown-linux release:
#
# - Builds release package
# - Uploads to Cloudsmith
#
# Tools required in the environment that runs this:
#
# - bash
# - cloudsmith-cli
# - GNU gzip
# - GNU make
# - ponyc
# - GNU tar

set -o errexit

# Pull in shared configuration specific to this repo
base=$(dirname "$0")
source "${base}/config.bash"

# Verify ENV is set up correctly
# We validate all that need to be set in case, in an absolute emergency,
# we need to run this by hand. Otherwise the GitHub actions environment should
# provide all of these if properly configured
if [[ -z "${CLOUDSMITH_API_KEY}" ]]; then
echo -e "\e[31mCloudsmith API key needs to be set in CLOUDSMITH_API_KEY."
echo -e "Exiting.\e[0m"
exit 1
fi

if [[ -z "${GITHUB_REPOSITORY}" ]]; then
echo -e "\e[31mName of this repository needs to be set in GITHUB_REPOSITORY."
echo -e "\e[31mShould be in the form OWNER/REPO, for example:"
echo -e "\e[31m ponylang/ponyup"
echo -e "\e[31mExiting.\e[0m"
exit 1
fi

if [[ -z "${APPLICATION_NAME}" ]]; then
echo -e "\e[31mAPPLICATION_NAME needs to be set."
echo -e "\e[31mExiting.\e[0m"
exit 1
fi

if [[ -z "${APPLICATION_SUMMARY}" ]]; then
echo -e "\e[31mAPPLICATION_SUMMARY needs to be set."
echo -e "\e[31mIt's a short description of the application that will appear in Cloudsmith."
echo -e "\e[31mExiting.\e[0m"
exit 1
fi

# no unset variables allowed from here on out
# allow above so we can display nice error messages for expected unset variables
set -o nounset

TODAY=$(date +%Y%m%d)

# Compiler target parameters
ARCH=x86-64

# Triple construction
VENDOR=apple
OS=darwin
TRIPLE=${ARCH}-${VENDOR}-${OS}

# Build parameters
BUILD_PREFIX=$(mktemp -d)
APPLICATION_VERSION="nightly-${TODAY}"
BUILD_DIR=${BUILD_PREFIX}/${APPLICATION_VERSION}

# Asset information
PACKAGE_DIR=$(mktemp -d)
PACKAGE=${APPLICATION_NAME}-${TRIPLE}

# Cloudsmith configuration
CLOUDSMITH_VERSION=${TODAY}
ASSET_OWNER=ponylang
ASSET_REPO=nightlies
ASSET_PATH=${ASSET_OWNER}/${ASSET_REPO}
ASSET_FILE=${PACKAGE_DIR}/${PACKAGE}.tar.gz
ASSET_SUMMARY="${APPLICATION_SUMMARY}"
ASSET_DESCRIPTION="https://github.com/${GITHUB_REPOSITORY}"

# Build application installation
echo -e "\e[34mBuilding ${APPLICATION_NAME}...\e[0m"
make install prefix="${BUILD_DIR}" arch=${ARCH} \
version="${APPLICATION_VERSION}"

# Package it all up
echo -e "\e[34mCreating .tar.gz of ${APPLICATION_NAME}...\e[0m"
pushd "${BUILD_PREFIX}" || exit 1
tar -cvzf "${ASSET_FILE}" *
popd || exit 1

# Ship it off to cloudsmith
echo -e "\e[34mUploading package to cloudsmith...\e[0m"
cloudsmith push raw --version "${CLOUDSMITH_VERSION}" \
--api-key "${CLOUDSMITH_API_KEY}" --summary "${ASSET_SUMMARY}" \
--description "${ASSET_DESCRIPTION}" ${ASSET_PATH} "${ASSET_FILE}"
99 changes: 99 additions & 0 deletions .ci-scripts/release/x86-64-apple-darwin-release.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#!/bin/bash

# x86-64-unknown-linux release:
#
# - Builds release package
# - Uploads to Cloudsmith
#
# Tools required in the environment that runs this:
#
# - bash
# - cloudsmith-cli
# - GNU gzip
# - GNU make
# - ponyc
# - GNU tar

set -o errexit

# Pull in shared configuration specific to this repo
base=$(dirname "$0")
source "${base}/config.bash"

# Verify ENV is set up correctly
# We validate all that need to be set in case, in an absolute emergency,
# we need to run this by hand. Otherwise the GitHub actions environment should
# provide all of these if properly configured
if [[ -z "${CLOUDSMITH_API_KEY}" ]]; then
echo -e "\e[31mCloudsmith API key needs to be set in CLOUDSMITH_API_KEY."
echo -e "Exiting.\e[0m"
exit 1
fi

if [[ -z "${GITHUB_REPOSITORY}" ]]; then
echo -e "\e[31mName of this repository needs to be set in GITHUB_REPOSITORY."
echo -e "\e[31mShould be in the form OWNER/REPO, for example:"
echo -e "\e[31m ponylang/ponyup"
echo -e "\e[31mExiting.\e[0m"
exit 1
fi

if [[ -z "${APPLICATION_NAME}" ]]; then
echo -e "\e[31mAPPLICATION_NAME needs to be set."
echo -e "\e[31mExiting.\e[0m"
exit 1
fi

if [[ -z "${APPLICATION_SUMMARY}" ]]; then
echo -e "\e[31mAPPLICATION_SUMMARY needs to be set."
echo -e "\e[31mIt's a short description of the application that will appear in Cloudsmith."
echo -e "\e[31mExiting.\e[0m"
exit 1
fi

# no unset variables allowed from here on out
# allow above so we can display nice error messages for expected unset variables
set -o nounset

# Compiler target parameters
ARCH=x86-64

# Triple construction
VENDOR=apple
OS=darwin
TRIPLE=${ARCH}-${VENDOR}-${OS}

# Build parameters
BUILD_PREFIX=$(mktemp -d)
APPLICATION_VERSION=$(cat VERSION)
BUILD_DIR=${BUILD_PREFIX}/${APPLICATION_VERSION}

# Asset information
PACKAGE_DIR=$(mktemp -d)
PACKAGE=${APPLICATION_NAME}-${TRIPLE}

# Cloudsmith configuration
CLOUDSMITH_VERSION=$(cat VERSION)
ASSET_OWNER=ponylang
ASSET_REPO=releases
ASSET_PATH=${ASSET_OWNER}/${ASSET_REPO}
ASSET_FILE=${PACKAGE_DIR}/${PACKAGE}.tar.gz
ASSET_SUMMARY="${APPLICATION_SUMMARY}"
ASSET_DESCRIPTION="https://github.com/${GITHUB_REPOSITORY}"

# Build application installation
echo -e "\e[34mBuilding ${APPLICATION_NAME}...\e[0m"
make install prefix="${BUILD_DIR}" arch=${ARCH} \
version="${APPLICATION_VERSION}"

# Package it all up
echo -e "\e[34mCreating .tar.gz of ${APPLICATION_NAME}...\e[0m"
pushd "${BUILD_PREFIX}" || exit 1
tar -cvzf "${ASSET_FILE}" *
popd || exit 1

# Ship it off to cloudsmith
echo -e "\e[34mUploading package to cloudsmith...\e[0m"
cloudsmith push raw --version "${CLOUDSMITH_VERSION}" \
--api-key "${CLOUDSMITH_API_KEY}" --summary "${ASSET_SUMMARY}" \
--description "${ASSET_DESCRIPTION}" ${ASSET_PATH} "${ASSET_FILE}"
5 changes: 1 addition & 4 deletions .ci-scripts/test-bootstrap.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#!/bin/sh

triple="$(cc -dumpmachine)"
libc="${triple##*-}"

rm -rf \
/usr/local/bin/ponyc \
/usr/local/bin/stable \
Expand All @@ -13,7 +10,7 @@ rm -rf \
cat ponyup-init.sh | sh -s -- --prefix=/usr/local

export PATH=$HOME/.local/share/ponyup/bin:$PATH
ponyup update ponyc nightly --libc=${libc}
ponyup update ponyc nightly "--platform=$(cc -dumpmachine)"
ponyup update changelog-tool nightly
ponyup update corral nightly
ponyup update stable nightly
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/nightlies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,18 @@ jobs:
env:
CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}

x86-64-apple-darwin-nightly:
name: Build and upload x86-64-apple-darwin-nightly to Cloudsmith
runs-on: macos-latest
steps:
- uses: actions/checkout@v1
- name: brew install ponyc
run: brew install ponyc
- name: brew install dependencies
run: brew install coreutils libressl python
- name: pip install dependencies
run: pip3 install --upgrade cloudsmith-cli
- name: Build and upload
run: bash .ci-scripts/release/x86-64-apple-darwin-nightly.bash
env:
CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}
19 changes: 16 additions & 3 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,28 @@ jobs:
- name: Verify CHANGELOG
run: changelog-tool verify

vs-ponyc-release:
name: Verify PR builds most recent ponyc release
linux:
name: Verify PR builds on Linux with most recent ponyc release
runs-on: ubuntu-latest
container:
image: ponylang/shared-docker-ci-x86-64-unknown-linux-builder-with-ssl:release
steps:
- uses: actions/checkout@v1
- name: Test with the most recent ponyc release
run: make test
run: PONYUP_PLATFORM=musl make test
- name: Bootstrap test
run: .ci-scripts/test-bootstrap.sh

macos:
name: Verify PR builds on macOS with most recent ponyc release
runs-on: macos-latest
steps:
- uses: actions/checkout@v1
- name: brew install ponyc
run: brew install ponyc
- name: brew install dependencies
run: brew install coreutils libressl
- name: Test with the most recent ponyc release
run: make test
- name: Bootstrap test
run: .ci-scripts/test-bootstrap.sh
20 changes: 18 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- \d+.\d+.\d+

jobs:
create-and-upload-a-release:
x86-64-unknown-linux-release:
name: Build and upload to Cloudsmith
runs-on: ubuntu-latest
container:
Expand All @@ -18,6 +18,22 @@ jobs:
env:
CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}

x86-64-apple-darwin-release:
name: Build and upload x86-64-apple-darwin-release to Cloudsmith
runs-on: macos-latest
steps:
- uses: actions/checkout@v1
- name: brew install ponyc
run: brew install ponyc
- name: brew install dependencies
run: brew install coreutils libressl python
- name: pip install dependencies
run: pip3 install --upgrade cloudsmith-cli
- name: Build and upload
run: bash .ci-scripts/release/x86-64-apple-darwin-release.bash
env:
CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}

build-release-docker-images:
name: Build and push release Docker images
runs-on: ubuntu-latest
Expand All @@ -36,7 +52,7 @@ jobs:
runs-on: ubuntu-latest
container:
image: ponylang/shared-docker-ci-release:20191107
needs: [create-and-upload-a-release, build-release-docker-images]
needs: [x86-64-unknown-linux-release, x86-64-apple-darwin-release, build-release-docker-images]
steps:
- uses: actions/checkout@v1
- name: Trigger release announcement
Expand Down
45 changes: 23 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,39 @@ SRC_DIR ?= cmd
binary := $(BUILD_DIR)/ponyup

ifdef config
ifeq (,$(filter $(config),debug release))
$(error Unknown configuration "$(config)")
endif
ifeq (,$(filter $(config),debug release))
$(error Unknown configuration "$(config)")
endif
endif

ifeq ($(config),debug)
PONYC_FLAGS += --debug
endif

ifeq ($(ssl), 1.1.x)
PONYC_FLAGS += -Dopenssl_1.1.x
PONYC_FLAGS += -Dopenssl_1.1.x
else ifeq ($(ssl), 0.9.0)
PONYC_FLAGS += -Dopenssl_0.9.0
PONYC_FLAGS += -Dopenssl_0.9.0
else
$(error Unknown SSL version "$(ssl)". Must set using 'ssl=FOO')
$(error Unknown SSL version "$(ssl)". Must set using 'ssl=FOO')
endif

ifneq ($(arch),)
PONYC_FLAGS += --cpu $(arch)
PONYC_FLAGS += --cpu $(arch)
endif

ifdef static
ifeq (,$(filter $(static),true false))
$(error "static must be true or false)
endif
ifeq (,$(filter $(static),true false))
$(error "static must be true or false)
endif
endif

ifeq ($(static),true)
LINKER += --static
LINKER += --static
endif

ifneq ($(linker),)
LINKER += --link-ldcmd=$(linker)
LINKER += --link-ldcmd=$(linker)
endif

# Default to version from `VERSION` file but allowing overridding on the
Expand All @@ -55,16 +55,16 @@ endif
# overridden version *should not* contain spaces or characters that aren't
# legal in filesystem path names
ifndef version
version := $(shell cat VERSION)
ifneq ($(wildcard .git),)
sha := $(shell git rev-parse --short HEAD)
tag := $(version)-$(sha)
else
tag := $(version)
endif
version := $(shell cat VERSION)
ifneq ($(wildcard .git),)
sha := $(shell git rev-parse --short HEAD)
tag := $(version)-$(sha)
else
tag := $(version)
endif
else
foo := $(shell touch VERSION)
tag := $(version)
foo := $(shell touch VERSION)
tag := $(version)
endif

SOURCE_FILES := $(shell find $(SRC_DIR) -path $(SRC_DIR)/test -prune -o -name \*.pony)
Expand All @@ -89,7 +89,8 @@ install: $(binary)
SOURCE_FILES := $(shell find cmd -name \*.pony)

test: $(binary)
./test/test.sh
stable env ponyc $(PONYC_FLAGS) $(LINKER) test -o $(BUILD_DIR) -b test
$(BUILD_DIR)/test ${ponytest_args}

clean:
rm -rf $(BUILD_DIR) $(GEN_FILES)
Expand Down
Loading