2022-08-09 02:50:24 +03:00
|
|
|
name: build
|
2022-11-04 15:59:20 +03:00
|
|
|
|
2022-08-09 02:50:24 +03:00
|
|
|
on:
|
|
|
|
workflow_call:
|
|
|
|
inputs:
|
|
|
|
projects:
|
|
|
|
required: true
|
|
|
|
type: string
|
|
|
|
|
2022-11-04 15:59:20 +03:00
|
|
|
env:
|
|
|
|
TEA_PANTRY_PATH: ${{ github.workspace }}/pantry
|
|
|
|
|
2022-08-09 02:50:24 +03:00
|
|
|
jobs:
|
|
|
|
build:
|
2022-12-21 00:54:26 +03:00
|
|
|
runs-on: ${{ matrix.platform.os }}
|
2022-08-09 02:50:24 +03:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2022-12-21 00:54:26 +03:00
|
|
|
platform:
|
2022-08-09 02:50:24 +03:00
|
|
|
- os: macos-11
|
2022-12-21 00:54:26 +03:00
|
|
|
name: darwin+x86-64
|
2023-01-07 01:24:49 +03:00
|
|
|
- os: ubuntu-latest-4-cores
|
2022-12-21 00:54:26 +03:00
|
|
|
name: linux+x86-64
|
2022-09-03 01:41:05 +03:00
|
|
|
container:
|
2022-09-29 21:14:58 +03:00
|
|
|
image: debian:buster-slim
|
2022-10-19 06:32:18 +03:00
|
|
|
- os: [self-hosted, macOS, ARM64]
|
2022-12-21 00:54:26 +03:00
|
|
|
name: darwin+aarch64
|
2022-10-19 06:32:18 +03:00
|
|
|
- os: [self-hosted, linux, ARM64]
|
2022-12-21 00:54:26 +03:00
|
|
|
name: linux+aarch64
|
|
|
|
container: ${{ matrix.platform.container }}
|
2022-08-09 02:50:24 +03:00
|
|
|
steps:
|
|
|
|
- name: co pantry
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
path: pantry
|
|
|
|
|
|
|
|
- name: co cli
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
path: cli
|
|
|
|
repository: teaxyz/cli
|
|
|
|
|
2022-10-28 01:23:32 +03:00
|
|
|
- uses: teaxyz/setup@v0
|
|
|
|
id: tea
|
|
|
|
with:
|
2022-11-04 15:59:20 +03:00
|
|
|
# necessary because we currently require a `.git` directory
|
2022-10-28 01:23:32 +03:00
|
|
|
srcroot: /opt/tea.xyz/var/pantry
|
|
|
|
prefix: /opt
|
|
|
|
|
2022-08-09 02:50:24 +03:00
|
|
|
- name: HACKS
|
|
|
|
run: |
|
2022-12-21 00:54:26 +03:00
|
|
|
case ${{ matrix.platform.os }} in
|
2022-08-09 02:50:24 +03:00
|
|
|
macos-11)
|
2022-10-04 03:38:14 +03:00
|
|
|
#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
|
2022-08-09 02:50:24 +03:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2022-11-04 15:59:20 +03:00
|
|
|
ln -s $GITHUB_WORKSPACE/cli /opt/tea.xyz/var/cli
|
2022-08-09 02:50:24 +03:00
|
|
|
|
2022-11-11 03:53:26 +03:00
|
|
|
# in case this PR contains updates to the scripts
|
|
|
|
#TODO only do for PRs
|
|
|
|
if test "$GITHUB_REPOSITORY" = "teaxyz/pantry.core"; then
|
|
|
|
cp -rv pantry/scripts/* /opt/tea.xyz/var/pantry/scripts
|
|
|
|
fi
|
|
|
|
|
2022-10-28 01:23:32 +03:00
|
|
|
- run: /opt/tea.xyz/var/pantry/scripts/sort.ts ${{ inputs.projects }}
|
2022-08-09 02:50:24 +03:00
|
|
|
id: sorted
|
|
|
|
|
2022-11-04 15:59:20 +03:00
|
|
|
# running out of /opt because only pantry.core has these scripts
|
2022-12-21 16:10:10 +03:00
|
|
|
- run: /opt/tea.xyz/var/pantry/scripts/build.ts ${{ steps.sorted.outputs.pkgs }}
|
2022-08-09 02:50:24 +03:00
|
|
|
id: build
|
|
|
|
env:
|
2022-11-11 04:42:08 +03:00
|
|
|
GITHUB_TOKEN: ${{ github.token }}
|
2022-08-09 02:50:24 +03:00
|
|
|
FORCE_UNSAFE_CONFIGURE: 1 # some configure scripts refuse to run as root
|
|
|
|
|
2022-12-21 00:54:26 +03:00
|
|
|
- name: delete `.la` files
|
|
|
|
run: find ${{ steps.tea.outputs.prefix }} -name '*.la' -delete
|
|
|
|
|
|
|
|
# cache data we'll need in the bottling job
|
|
|
|
- run: |
|
|
|
|
echo ${{ steps.build.outputs.pkgs }} >built
|
|
|
|
echo ${{ steps.build.outputs.relative-paths }} >relative-paths
|
|
|
|
echo ${{ steps.build.outputs.srcs }} >srcs
|
|
|
|
working-directory: ${{ steps.tea.outputs.prefix }}
|
|
|
|
|
2022-09-29 19:07:07 +03:00
|
|
|
# tarring ourselves ∵ GHA-artifacts (ludicrously) lose permissions
|
|
|
|
# /ref https://github.com/actions/upload-artifact/issues/38
|
2022-10-17 20:45:32 +03:00
|
|
|
- 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-12-21 00:54:26 +03:00
|
|
|
built relative-paths srcs
|
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-12-21 00:54:26 +03:00
|
|
|
name: ${{ matrix.platform.name }}
|
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-12-21 00:54:26 +03:00
|
|
|
runs-on: ${{ matrix.platform.os }}
|
2022-09-08 23:40:35 +03:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2022-12-21 00:54:26 +03:00
|
|
|
platform:
|
2022-09-29 19:07:07 +03:00
|
|
|
- os: macos-11
|
2022-12-21 00:54:26 +03:00
|
|
|
name: darwin+x86-64
|
2022-09-29 19:07:07 +03:00
|
|
|
- os: ubuntu-latest
|
2022-12-21 00:54:26 +03:00
|
|
|
name: linux+x86-64
|
2022-09-29 19:07:07 +03:00
|
|
|
- os: ubuntu-latest
|
2022-12-21 00:54:26 +03:00
|
|
|
name: linux+x86-64
|
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
|
2022-12-21 00:54:26 +03:00
|
|
|
name: linux+x86-64
|
2022-09-29 19:07:07 +03:00
|
|
|
container: debian:buster-slim
|
2022-10-19 06:32:18 +03:00
|
|
|
- os: [self-hosted, macOS, ARM64]
|
2022-12-21 00:54:26 +03:00
|
|
|
name: darwin+aarch64
|
2022-10-19 06:32:18 +03:00
|
|
|
- os: [self-hosted, linux, ARM64]
|
2022-12-21 00:54:26 +03:00
|
|
|
name: linux+aarch64
|
2023-01-06 03:05:18 +03:00
|
|
|
outputs:
|
|
|
|
HAS_SECRETS: ${{ secrets.AWS_S3_CACHE != '' }}
|
2022-12-21 00:54:26 +03:00
|
|
|
container: ${{ matrix.platform.container }}
|
2022-09-08 23:40:35 +03:00
|
|
|
steps:
|
2022-09-29 02:19:56 +03:00
|
|
|
- uses: actions/checkout@v3
|
2022-09-08 23:40:35 +03:00
|
|
|
with:
|
2022-10-28 01:23:32 +03:00
|
|
|
path: tea.xyz/var/cli
|
2022-09-08 23:40:35 +03:00
|
|
|
repository: teaxyz/cli
|
|
|
|
|
2022-11-04 15:59:20 +03:00
|
|
|
- uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
path: pantry
|
2022-09-29 22:40:34 +03:00
|
|
|
|
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-28 01:23:32 +03:00
|
|
|
srcroot: tea.xyz/var/pantry
|
2022-09-29 02:19:56 +03:00
|
|
|
prefix: ${{ github.workspace }}
|
2022-10-26 04:55:49 +03:00
|
|
|
|
2022-11-04 15:59:20 +03:00
|
|
|
- run: |
|
2022-12-21 22:07:10 +03:00
|
|
|
# in case this PR contains updates to the scripts TODO only PRs
|
2022-12-07 22:33:13 +03:00
|
|
|
if test "$GITHUB_REPOSITORY" = "teaxyz/pantry.core"; then
|
|
|
|
cp -rv pantry/scripts/* $(tea --prefix)/tea.xyz/var/pantry/scripts
|
|
|
|
fi
|
2022-12-21 00:54:26 +03:00
|
|
|
if: ${{ matrix.platform.container != '' }}
|
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-12-21 00:54:26 +03:00
|
|
|
name: ${{ matrix.platform.name }}
|
2022-09-08 23:40:35 +03:00
|
|
|
|
2022-09-29 19:07:07 +03:00
|
|
|
- run: tar xzf artifacts.tgz
|
|
|
|
|
2022-10-28 01:23:32 +03:00
|
|
|
- run: tea.xyz/var/pantry/scripts/test.ts ${{ inputs.projects }}
|
2022-09-08 23:40:35 +03:00
|
|
|
|
2022-12-21 00:54:26 +03:00
|
|
|
stage:
|
|
|
|
needs: [test]
|
2023-01-06 02:31:35 +03:00
|
|
|
# this only works for PRs from our team to our repo (security! :( )
|
2023-01-06 03:05:18 +03:00
|
|
|
if: startsWith(github.ref, 'refs/pull/') && startsWith(github.repository, 'teaxyz/pantry.') && needs.test.outputs.HAS_SECRETS
|
2022-12-21 00:54:26 +03:00
|
|
|
runs-on: ubuntu-latest
|
2022-09-26 17:56:15 +03:00
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
platform:
|
2022-10-19 06:32:18 +03:00
|
|
|
- os: macos-11
|
2022-11-30 23:18:05 +03:00
|
|
|
name: darwin+x86-64
|
2022-10-19 06:32:18 +03:00
|
|
|
- os: ubuntu-latest
|
2022-11-30 23:18:05 +03:00
|
|
|
name: linux+x86-64
|
2022-10-19 06:32:18 +03:00
|
|
|
- os: [self-hosted, macOS, ARM64]
|
2022-11-30 23:18:05 +03:00
|
|
|
name: darwin+aarch64
|
2022-10-19 06:32:18 +03:00
|
|
|
- os: [self-hosted, linux, ARM64]
|
2022-11-30 23:18:05 +03:00
|
|
|
name: linux+aarch64
|
2022-09-26 17:56:15 +03:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
with:
|
2022-11-04 15:59:20 +03:00
|
|
|
path: tea.xyz/var/cli
|
|
|
|
repository: teaxyz/cli
|
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-11-04 15:59:20 +03:00
|
|
|
path: pantry
|
2022-09-26 17:56:15 +03:00
|
|
|
|
|
|
|
- uses: teaxyz/setup@v0
|
|
|
|
id: tea
|
2022-09-29 02:19:56 +03:00
|
|
|
with:
|
2022-10-28 01:23:32 +03:00
|
|
|
srcroot: tea.xyz/var/pantry
|
2022-09-29 02:19:56 +03:00
|
|
|
prefix: ${{ github.workspace }}
|
2022-09-26 17:56:15 +03:00
|
|
|
|
2022-12-07 22:33:13 +03:00
|
|
|
- run: |
|
|
|
|
# in case this PR contains updates to the scripts
|
|
|
|
#TODO only do for PRs
|
|
|
|
if test "$GITHUB_REPOSITORY" = "teaxyz/pantry.core"; then
|
|
|
|
cp -rv $GITHUB_WORKSPACE/pantry/scripts/* $(tea --prefix)/tea.xyz/var/pantry/scripts
|
|
|
|
fi
|
|
|
|
|
2022-09-28 18:14:46 +03:00
|
|
|
- uses: actions/download-artifact@v3
|
2022-09-26 17:56:15 +03:00
|
|
|
with:
|
2022-12-21 00:54:26 +03:00
|
|
|
name: ${{ matrix.platform.name }}
|
2022-12-07 22:33:13 +03:00
|
|
|
|
2022-12-21 00:54:26 +03:00
|
|
|
- run:
|
|
|
|
tea.xyz/var/pantry/scripts/cache-artifacts.ts
|
|
|
|
${{github.repository}}
|
|
|
|
${{github.ref}}
|
|
|
|
${{matrix.platform.name}}
|
|
|
|
artifacts.tgz
|
2022-09-28 18:14:46 +03:00
|
|
|
env:
|
2022-12-21 00:54:26 +03:00
|
|
|
AWS_S3_CACHE: ${{ secrets.AWS_S3_CACHE }}
|
2022-09-28 18:14:46 +03:00
|
|
|
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|