pantry/.github/workflows/build.yml

251 lines
7.8 KiB
YAML
Raw Normal View History

name: build
on:
workflow_call:
inputs:
projects:
required: true
type: string
2022-10-26 15:16:43 +03:00
upload:
required: false
type: boolean
default: false
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: macos-11
- os: ubuntu-latest
2022-09-03 01:41:05 +03:00
container:
image: debian:buster-slim
2022-09-03 01:41:05 +03:00
options: --memory=16g
2022-10-19 06:32:18 +03:00
- os: [self-hosted, macOS, ARM64]
tag: darwin-aarch64
- os: [self-hosted, linux, ARM64]
tag: linux-aarch64
container: ${{ matrix.container }}
2022-09-08 23:40:35 +03:00
outputs:
2022-09-27 22:11:35 +03:00
built: ${{ steps.build.outputs.pkgs }}
srcs: ${{ steps.build.outputs.srcs }}
2022-09-08 23:40:35 +03:00
pkgs: ${{ steps.sorted.outputs.pkgs }} ${{ steps.sorted.outputs.pre-install }}
steps:
- name: co pantry
uses: actions/checkout@v3
with:
path: pantry
- name: co cli
uses: actions/checkout@v3
with:
path: cli
repository: teaxyz/cli
token: ${{ secrets.TEMP_JACOBS_GITHUB_PAT }}
- name: HACKS
run: |
case ${{ matrix.os }} in
ubuntu-latest)
#FIXME our LLVM doesn't provide c/c++ headers for some reason
apt-get update
apt-get --yes install libc-dev libstdc++-8-dev libgcc-8-dev
;;
macos-11)
#FIXME we need a clean install of macOS for builds
#TODO stop using GHA images or chroot or something
2022-09-02 00:42:09 +03:00
for x in /usr/local/*; do sudo mv $x /tmp; done
;;
esac
2022-10-26 04:55:49 +03:00
- uses: teaxyz/setup@v0
id: tea
with:
srcroot: pantry
prefix: /opt
- name: prepare pantries
run: |
2022-10-26 23:39:40 +03:00
# Ensures the pantry paths within our tea environment exist, and are as synchronized
# as might be needed in the future; we then copy the contents of our checkout into
# them (excluding symlinks -- `cp`s all handle them differently and they aren't needed
# here) to allow access to any new code being merged into PR/CI.
2022-10-26 04:55:49 +03:00
tea --sync
2022-10-26 08:23:29 +03:00
find $GITHUB_WORKSPACE/pantry \
-not -type l \
-mindepth 1 \
-maxdepth 1 \
-print0 | \
xargs -0 -I{} cp -Rv {} /opt/tea.xyz/var/pantry
2022-09-29 19:07:07 +03:00
- run: pantry/scripts/sort.ts ${{ inputs.projects }}
id: sorted
2022-09-29 19:07:07 +03:00
- run: cli/scripts/install.ts ${{ steps.sorted.outputs.pre-install }}
2022-09-01 20:49:14 +03:00
2022-09-29 19:07:07 +03:00
- run: pantry/scripts/build.ts ${{ steps.sorted.outputs.pkgs }}
id: build
env:
2022-09-28 18:14:46 +03:00
# GITHUB_TOKEN doesn't have private access to teaxyz/cli.
# TODO restore to ${{ github.token }} when public
2022-09-23 16:44:25 +03:00
GITHUB_TOKEN: ${{ secrets.TEMP_JACOBS_GITHUB_PAT }}
FORCE_UNSAFE_CONFIGURE: 1 # some configure scripts refuse to run as root
2022-09-29 19:07:07 +03:00
# tarring ourselves ∵ GHA-artifacts (ludicrously) lose permissions
# /ref https://github.com/actions/upload-artifact/issues/38
- run:
tar czf $GITHUB_WORKSPACE/artifacts.tgz
${{ steps.build.outputs.relative-paths }}
2022-10-17 22:20:42 +03:00
${{ steps.build.outputs.srcs-relative-paths }}
2022-09-29 19:07:07 +03:00
working-directory: ${{ steps.tea.outputs.prefix }}
2022-09-10 11:09:40 +03:00
- name: upload artifacts
uses: actions/upload-artifact@v3
with:
2022-10-19 06:32:18 +03:00
name: ${{ matrix.tag || matrix.os }}
2022-09-29 19:07:07 +03:00
path: artifacts.tgz
2022-09-10 11:09:40 +03:00
if-no-files-found: error
2022-09-28 18:14:46 +03:00
test:
2022-09-10 11:09:40 +03:00
needs: [build]
2022-09-08 23:40:35 +03:00
runs-on: ${{ matrix.os }}
strategy:
matrix:
2022-09-29 19:07:07 +03:00
include:
- os: macos-11
- os: ubuntu-latest
- os: ubuntu-latest
2022-10-06 19:14:37 +03:00
container: ghcr.io/teaxyz/infuser:slim-latest
2022-09-29 19:07:07 +03:00
- os: ubuntu-latest
container: debian:buster-slim
2022-10-19 06:32:18 +03:00
- os: [self-hosted, macOS, ARM64]
tag: darwin-aarch64
- os: [self-hosted, linux, ARM64]
tag: linux-aarch64
2022-09-29 19:07:07 +03:00
container: ${{ matrix.container }}
2022-09-08 23:40:35 +03:00
steps:
- uses: actions/checkout@v3
with:
2022-10-26 04:55:49 +03:00
path: pantry
2022-09-08 23:40:35 +03:00
2022-09-29 02:19:56 +03:00
- uses: actions/checkout@v3
2022-09-08 23:40:35 +03:00
with:
2022-10-26 04:55:49 +03:00
path: cli
2022-09-08 23:40:35 +03:00
repository: teaxyz/cli
token: ${{ secrets.TEMP_JACOBS_GITHUB_PAT }}
2022-09-29 22:40:34 +03:00
- run: |
apt-get update
apt-get --yes install libc-dev libstdc++-8-dev libgcc-8-dev
2022-09-29 22:40:34 +03:00
if: ${{ matrix.container != '' }}
2022-09-08 23:40:35 +03:00
- uses: teaxyz/setup@v0
id: tea
2022-09-29 02:19:56 +03:00
with:
2022-10-26 04:55:49 +03:00
srcroot: pantry
2022-09-29 02:19:56 +03:00
prefix: ${{ github.workspace }}
2022-10-26 04:55:49 +03:00
- name: overlay this pantry
2022-10-26 08:23:29 +03:00
run: |
tea --sync
find $GITHUB_WORKSPACE/pantry \
-not -type l \
-mindepth 1 \
-maxdepth 1 \
-print0 | \
xargs -0 -I{} cp -Rv {} $GITHUB_WORKSPACE/tea.xyz/var/pantry
2022-09-08 23:40:35 +03:00
2022-09-28 18:14:46 +03:00
- uses: actions/download-artifact@v3
2022-09-08 23:40:35 +03:00
with:
2022-10-19 06:32:18 +03:00
name: ${{ matrix.tag || matrix.os }}
2022-09-08 23:40:35 +03:00
2022-09-29 19:07:07 +03:00
- run: tar xzf artifacts.tgz
working-directory: ${{ steps.tea.outputs.prefix }}
2022-10-26 04:55:49 +03:00
- run: pantry/scripts/test.ts ${{ inputs.projects }}
2022-09-08 23:40:35 +03:00
2022-09-28 18:14:46 +03:00
bottle:
needs: [test, build]
2022-10-19 06:32:18 +03:00
runs-on: ${{ matrix.platform.os }}
2022-09-26 17:56:15 +03:00
strategy:
matrix:
platform:
2022-10-19 06:32:18 +03:00
- os: macos-11
- os: ubuntu-latest
- os: [self-hosted, macOS, ARM64]
tag: darwin-aarch64
- os: [self-hosted, linux, ARM64]
tag: linux-aarch64
2022-09-26 17:56:15 +03:00
steps:
- uses: actions/checkout@v3
with:
2022-10-26 04:55:49 +03:00
path: pantry
2022-09-26 17:56:15 +03:00
2022-09-29 02:19:56 +03:00
- uses: actions/checkout@v3
2022-09-26 17:56:15 +03:00
with:
2022-10-26 04:55:49 +03:00
path: cli
2022-09-26 17:56:15 +03:00
repository: teaxyz/cli
token: ${{ secrets.TEMP_JACOBS_GITHUB_PAT }}
- uses: teaxyz/setup@v0
id: tea
2022-09-29 02:19:56 +03:00
with:
2022-10-26 04:55:49 +03:00
srcroot: pantry
2022-09-29 02:19:56 +03:00
prefix: ${{ github.workspace }}
2022-09-26 17:56:15 +03:00
2022-09-28 18:14:46 +03:00
- uses: actions/download-artifact@v3
2022-09-26 17:56:15 +03:00
with:
2022-10-19 06:32:18 +03:00
name: ${{ matrix.platform.tag || matrix.platform.os }}
2022-09-26 17:56:15 +03:00
path: ${{ steps.tea.outputs.prefix }}
2022-09-29 19:07:07 +03:00
- run: tar xzf artifacts.tgz
working-directory: ${{ steps.tea.outputs.prefix }}
2022-10-26 04:55:49 +03:00
- run: pantry/scripts/bottle.ts ${{ needs.build.outputs.built }}
id: bottle-xz
2022-09-26 17:56:15 +03:00
env:
COMPRESSION: xz
2022-10-26 04:55:49 +03:00
- run: pantry/scripts/bottle.ts ${{ needs.build.outputs.built }}
id: bottle-gz
env:
COMPRESSION: gz
2022-09-28 18:14:46 +03:00
2022-09-26 17:56:15 +03:00
- name: upload bottles
2022-09-28 18:14:46 +03:00
id: upload
2022-10-26 15:16:43 +03:00
if: ${{ inputs.upload }}
2022-10-26 04:55:49 +03:00
run: pantry/scripts/upload.ts
--pkgs ${{ needs.build.outputs.built }} ${{ needs.build.outputs.built }}
--srcs ${{ needs.build.outputs.srcs }} ${{ needs.build.outputs.srcs }}
--bottles ${{ steps.bottle-gz.outputs.bottles }} ${{ steps.bottle-xz.outputs.bottles }}
--checksums ${{ steps.bottle-gz.outputs.checksums }} ${{ steps.bottle-xz.outputs.checksums }}
2022-09-26 17:56:15 +03:00
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
2022-09-28 18:14:46 +03:00
#NOTE ideally wed invalidate all at once so this is atomic
# however GHA cant consolidate outputs from a matrix :/
- uses: chetan/invalidate-cloudfront-action@v2
2022-10-26 15:16:43 +03:00
if: ${{ inputs.upload }}
2022-09-28 18:14:46 +03:00
env:
PATHS: ${{ steps.upload.outputs.cf-invalidation-paths }}
DISTRIBUTION: ${{ secrets.AWS_CF_DISTRIBUTION_ID }}
AWS_REGION: us-east-1
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
2022-09-26 17:56:15 +03:00
2022-08-30 02:13:00 +03:00
notify:
if: always()
2022-09-28 18:14:46 +03:00
needs: [bottle]
2022-08-30 02:13:00 +03:00
runs-on: ubuntu-latest
steps:
2022-09-29 01:59:30 +03:00
- uses: martialonline/workflow-status@v3
id: status
2022-08-30 02:13:00 +03:00
- uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_CHANNEL: ${{ secrets.SLACK_CHANNEL }}
2022-09-29 01:59:30 +03:00
SLACK_MESSAGE: build job for ${{ inputs.projects }} ${{ steps.status.outputs.status }}
SLACK_COLOR: ${{ steps.status.outputs.status }}