pantry/.github/workflows/build.yml

184 lines
5.6 KiB
YAML
Raw Normal View History

name: build
on:
workflow_call:
inputs:
projects:
required: true
type: string
platform:
required: true
type: string
new-version:
type: boolean
required: false
default: false
jobs:
get-platform:
runs-on: ubuntu-latest
outputs:
os: ${{ steps.platform.outputs.os }}
build-os: ${{ steps.platform.outputs.build-os }}
2023-02-03 01:36:03 +03:00
container: ${{ steps.platform.outputs.container }}
test-matrix: ${{ steps.platform.outputs.test-matrix }}
cache-set: ${{ steps.platform.outputs.cache-set }}
steps:
- uses: actions/checkout@v3
with:
repository: teaxyz/pantry.core
2023-02-11 15:29:19 +03:00
- uses: actions/cache@v3
with:
path: $HOME/.cache/deno
2023-02-05 03:10:30 +03:00
key: ${{ runner.os }}-deno-get-platform-${{ hashFiles('deno.jsonc')}}
- uses: teaxyz/setup@v0
- run: scripts/get-platform.ts ${{ inputs.projects }}
id: platform
env:
PLATFORM: ${{ inputs.platform }}
TEA_PANTRY_PATH: ${{ github.workspace }}
build:
runs-on: ${{ fromJson(needs.get-platform.outputs.build-os) }}
2023-02-03 01:36:03 +03:00
container: ${{ fromJson(needs.get-platform.outputs.container) }}
needs: [get-platform]
steps:
- uses: actions/checkout@v3
2023-02-11 15:29:19 +03:00
- uses: actions/cache@v3
with:
path: ${{ needs.get-platform.outputs.cache-set }}
2023-02-05 03:10:30 +03:00
key: ${{ runner.os }}-deno-build-${{ hashFiles('deno.jsonc')}}
2022-10-28 01:23:32 +03:00
- uses: teaxyz/setup@v0
id: tea
with:
prefix: /opt
- name: sanitize macOS runners
if: matrix.platform.os == 'macos-11'
run: sudo mv /usr/local/bin/* /tmp/
- name: configure tea env
run: |
echo "$PWD/scripts:$TEA_PREFIX/tea.xyz/var/pantry/scripts" >> $GITHUB_PATH
echo "TEA_PANTRY_PATH=$GITHUB_WORKSPACE" >> $GITHUB_ENV
2023-02-11 13:52:24 +03:00
- run: tea +tea.xyz/brewkit build ${{ inputs.projects }}
id: build
env:
2022-11-11 04:42:08 +03:00
GITHUB_TOKEN: ${{ github.token }}
FORCE_UNSAFE_CONFIGURE: 1 # some configure scripts refuse to run as root
- name: delete `.la` files
run: find . -name '*.la' -delete
working-directory: ${{ steps.tea.outputs.prefix }}
# cache data we'll need in the bottling job
- name: assemble artifact metadata
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
- name: create artifacts.tgz
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 }}
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:
name: ${{ inputs.platform }}
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:
needs: [get-platform, build]
runs-on: ${{ matrix.platform.os }}
2022-09-08 23:40:35 +03:00
strategy:
fail-fast: false
2022-09-08 23:40:35 +03:00
matrix:
platform: ${{ fromJson(needs.get-platform.outputs.test-matrix) }}
outputs:
2023-01-12 01:00:05 +03:00
HAS_SECRETS: ${{ env.HAS_SECRETS }}
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
2023-02-11 13:52:24 +03:00
2023-02-11 15:29:19 +03:00
- uses: actions/cache@v3
with:
path: ${{ needs.get-platform.outputs.cache-set }}
2023-02-05 03:10:30 +03:00
key: ${{ runner.os }}-deno-test-${{ hashFiles('deno.jsonc')}}
2022-10-26 04:55:49 +03:00
2023-02-11 13:52:24 +03:00
- uses: teaxyz/setup@v0
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:
name: ${{ inputs.platform }}
2022-09-08 23:40:35 +03:00
- name: extract bottles
run: tar xzf artifacts.tgz -C $TEA_PREFIX
2022-09-29 19:07:07 +03:00
2023-02-11 13:52:24 +03:00
- run: tea +tea.xyz/brewkit test ${{ inputs.projects }}
env:
TEA_PANTRY_PATH: ${{ github.workspace }}
2022-09-08 23:40:35 +03:00
- name: post
run:
2023-01-12 01:00:05 +03:00
echo "HAS_SECRETS=$HAS_SECRETS" >>$GITHUB_ENV
env:
HAS_SECRETS: ${{ secrets.AWS_S3_CACHE != null }}
bottle:
needs: [test]
if: inputs.new-version == true
uses: ./.github/workflows/bottle.yml
with:
new-version: ${{ inputs.new-version }}
platform: ${{ inputs.platform }}
secrets: inherit
complain:
needs: [test]
if: inputs.new-version == true && failure()
uses: ./.github/workflows/complain.yml
with:
projects: ${{ inputs.projects }}
platform: ${{ inputs.platform }}
secrets: inherit
stage:
needs: [test]
# this only works for PRs from our team to our repo (security! :( )
2023-01-12 01:00:05 +03:00
if: startsWith(github.ref, 'refs/pull/') && startsWith(github.repository, 'teaxyz/pantry.') && needs.test.outputs.HAS_SECRETS == 'true'
runs-on: ubuntu-latest
2022-09-26 17:56:15 +03:00
steps:
- uses: actions/checkout@v3
2023-02-11 15:29:19 +03:00
- uses: actions/cache@v3
with:
path: $HOME/.cache/deno
2023-02-05 03:10:30 +03:00
key: ${{ runner.os }}-deno-stage-${{ hashFiles('deno.jsonc')}}
2022-09-26 17:56:15 +03:00
- uses: teaxyz/setup@v0
- name: configure scripts PATH
run: echo "$PWD/scripts:$TEA_PREFIX/tea.xyz/var/pantry/scripts" >> $GITHUB_PATH
2022-09-28 18:14:46 +03:00
- uses: actions/download-artifact@v3
2022-09-26 17:56:15 +03:00
with:
name: ${{ inputs.platform }}
- run: cache-artifacts.ts
${{github.repository}}
${{github.ref}}
${{inputs.platform}}
artifacts.tgz
2022-09-28 18:14:46 +03:00
env:
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 }}