Co-authored-by: robertkasza <167509084+robertkasza@users.noreply.github.com> Co-authored-by: Nuno Pato <nunopato@gmail.com> Co-authored-by: David BM <correodelnino@gmail.com>
89 lines
2.6 KiB
YAML
89 lines
2.6 KiB
YAML
---
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
NAME:
|
|
type: string
|
|
required: true
|
|
PATH:
|
|
type: string
|
|
required: true
|
|
GIT_REF:
|
|
type: string
|
|
required: false
|
|
secrets:
|
|
AWS_ACCOUNT_ID:
|
|
required: true
|
|
NIX_CACHE_PUB_KEY:
|
|
required: true
|
|
NIX_CACHE_PRIV_KEY:
|
|
required: true
|
|
|
|
jobs:
|
|
tests:
|
|
runs-on: blacksmith-2vcpu-ubuntu-2404
|
|
timeout-minutes: 30
|
|
|
|
defaults:
|
|
run:
|
|
working-directory: ${{ inputs.PATH }}
|
|
|
|
permissions:
|
|
id-token: write
|
|
contents: write
|
|
actions: read
|
|
|
|
steps:
|
|
- name: "Check out repository"
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
ref: ${{ inputs.GIT_REF }}
|
|
|
|
- name: Collect Workflow Telemetry
|
|
uses: catchpoint/workflow-telemetry-action@v2
|
|
with:
|
|
comment_on_pr: false
|
|
|
|
- name: Configure aws
|
|
uses: aws-actions/configure-aws-credentials@v4
|
|
with:
|
|
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/github-actions-nhost-${{ github.event.repository.name }}
|
|
aws-region: eu-central-1
|
|
|
|
- uses: cachix/install-nix-action@v31
|
|
with:
|
|
install_url: "https://releases.nixos.org/nix/nix-2.22.3/install"
|
|
install_options: "--no-daemon"
|
|
extra_nix_config: |
|
|
experimental-features = nix-command flakes
|
|
sandbox = false
|
|
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
|
|
substituters = https://cache.nixos.org/?priority=40 s3://nhost-nix-cache?region=eu-central-1&priority=50
|
|
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= ${{ secrets.NIX_CACHE_PUB_KEY }}
|
|
|
|
- name: "Verify if we need to build"
|
|
id: verify-build
|
|
run: |
|
|
export drvPath=$(make check-dry-run)
|
|
nix store verify --no-trust --store s3://nhost-nix-cache\?region=eu-central-1 $drvPath \
|
|
&& export BUILD_NEEDED=no \
|
|
|| export BUILD_NEEDED=yes
|
|
echo BUILD_NEEDED=$BUILD_NEEDED >> $GITHUB_OUTPUT
|
|
echo DERIVATION_PATH=$drvPath >> $GITHUB_OUTPUT
|
|
|
|
- name: "Start containters for integration tests"
|
|
run: |
|
|
nix develop .\#${{ inputs.NAME }} -c make dev-env-up
|
|
if: ${{ steps.verify-build.outputs.BUILD_NEEDED == 'yes' }}
|
|
|
|
- name: "Run checks"
|
|
run: make check
|
|
if: ${{ steps.verify-build.outputs.BUILD_NEEDED == 'yes' }}
|
|
|
|
- name: "Cache build"
|
|
run: |
|
|
nix store sign --key-file <(echo "${{ secrets.NIX_CACHE_PRIV_KEY }}") --all
|
|
find /nix/store -maxdepth 1 -name "*-*" -type d | xargs -n 25 nix copy --to s3://nhost-nix-cache\?region=eu-central-1
|
|
if: always()
|