Skip to content

Commit

Permalink
ci: Migrate to GH Actions for release (#4947)
Browse files Browse the repository at this point in the history
* ci(github): Build Linux engines (#1)

* add run-name

* fix: add target_path to Linux Status (x86_64) (#3)

* chore: update actions and autoformat

* ci: do all the things `engineer` CLI does for releasing engines (#4)

* remove /target from cache

* add release if github.event_name == 'workflow_dispatch'

* Comment out push/pr triggers

* Run on PR (tmp)

* Remove old pipelines, make commit optional

* Run linux jobs in docker containers

* Revert "Run linux jobs in docker containers"

This reverts commit aa6e6cc.

* Remove explicit repository

* Try to mount cache dirs, use rust-toolchain files

* No quotes

* Add osx arm toolchain

* Uncomment s3 upload

* Fix shellcheck

* Correct bucket

* Comment out R2

* Setup R2 uploads again

* Add workflow-dispatch for engines-wrapper

* Fix script

* Use github.sha everywhere

* Use prisma bot token

* Use repository dispatch

* Use short branch name

* Correct repo for dispatch

* head-ref?

* Skip engines build if no release is necessary

* Add all DBs tested on buildkite to GH Actions

* Split qe test job into multiple jobs because FML

* Adjust job/workflows names

* And again

* Run mysql as single threaded

* Ignore joins test on old mysql

* Bring back mariadb

* Organize pipelines better

* Add order by to fix postgres9

* Move DA tests into unified view

* Cleanup

* Address some of the review comments

* Pull command construction into separate script

[integration]

* Correctly check for [integration]

[integration]

* PR-safe way of getting commit message

[integration]

* n1

[integration]

* Correct multiline string

[integration]

* Checkout different ref

[integration]

* Try more things

[integration]

* Fix shellcheck

[integration]

* Check repository owner

[integration]

* I am sad

[integration]

* permissions?

* Revert to prisma bot token

* Revert back to membership check

[integration]

* Please

[integration]

* Uncomment triggers

---------

Co-authored-by: Jan Piotrowski <piotrowski+github@gmail.com>
Co-authored-by: Joël Galeran <Jolg42@users.noreply.github.com>
  • Loading branch information
3 people authored Jul 22, 2024
1 parent 68bfdeb commit f66d888
Show file tree
Hide file tree
Showing 16 changed files with 1,522 additions and 260 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
name: Build Engines for Apple Intel

on:
workflow_dispatch:
workflow_call:
inputs:
commit:
description: "Commit on the given branch to build"
description: 'Commit on the given branch to build'
type: string
required: false

jobs:
build:
# Do not change `name`, prisma-engines Buildkite build job depends on this name ending with the commit
name: "MacOS Intel engines build on branch ${{ github.event.ref }} for commit ${{ github.event.inputs.commit }}"
name: 'MacOS Intel engines build for commit ${{ inputs.commit }}'
env:
SQLITE_MAX_VARIABLE_NUMBER: 250000
SQLITE_MAX_EXPR_DEPTH: 10000
Expand All @@ -20,12 +21,12 @@ jobs:

steps:
- name: Output link to real commit
run: echo ${{ github.repository }}/commit/${{ github.event.inputs.commit }}
run: echo ${{ github.repository }}/commit/${{ inputs.commit }}

- name: Checkout ${{ github.event.inputs.commit }}
- name: Checkout ${{ inputs.commit }}
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.commit }}
ref: ${{ inputs.commit }}

- uses: actions-rust-lang/setup-rust-toolchain@v1

Expand All @@ -35,16 +36,27 @@ jobs:
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-intel-cargo-${{ hashFiles('**/Cargo.lock') }}
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- run: |
cargo build --release -p query-engine -p query-engine-node-api -p schema-engine-cli -p prisma-fmt
- name: Rename files
working-directory: ${{ github.workspace }}/target/release/
run: |
echo "Files in target/release before renaming"
ls -la .
mv libquery_engine.dylib libquery_engine.dylib.node
echo "Files in target/release after renaming"
ls -la .
- uses: actions/upload-artifact@v4
with:
name: binaries
name: darwin
path: |
${{ github.workspace }}/target/release/schema-engine
${{ github.workspace }}/target/release/prisma-fmt
${{ github.workspace }}/target/release/query-engine
${{ github.workspace }}/target/release/libquery_engine.dylib
${{ github.workspace }}/target/release/libquery_engine.dylib.node
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
name: Build Engines for Apple Silicon

on:
workflow_dispatch:
workflow_call:
inputs:
commit:
description: "Commit on the given branch to build"
description: 'Commit on the given branch to build'
type: string
required: false

jobs:
build:
# Do not change `name`, prisma-engines Buildkite build job depends on this name ending with the commit
name: "MacOS ARM64 (Apple Silicon) engines build on branch ${{ github.event.ref }} for commit ${{ github.event.inputs.commit }}"
name: 'MacOS ARM64 (Apple Silicon) engines build for commit ${{ inputs.commit }}'
env:
SQLITE_MAX_VARIABLE_NUMBER: 250000
SQLITE_MAX_EXPR_DEPTH: 10000
runs-on: macos-13

steps:
- name: Output link to real commit
run: echo ${{ github.repository }}/commit/${{ github.event.inputs.commit }}
run: echo ${{ github.repository }}/commit/${{ inputs.commit }}

- name: Checkout ${{ github.event.inputs.commit }}
- name: Checkout ${{ inputs.commit }}
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.commit }}
ref: ${{ inputs.commit }}

- uses: actions-rust-lang/setup-rust-toolchain@v1
- run: xcodebuild -showsdks

- name: Install aarch64 toolchain
run: rustup target add aarch64-apple-darwin
- uses: actions-rust-lang/setup-rust-toolchain@v1

- uses: actions/cache@v4
with:
Expand All @@ -37,16 +37,25 @@ jobs:
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- run: xcodebuild -showsdks

- run: |
cargo build --target=aarch64-apple-darwin --release -p query-engine -p query-engine-node-api -p schema-engine-cli -p prisma-fmt
- name: Rename files
working-directory: ${{ github.workspace }}/target/aarch64-apple-darwin/release
run: |
echo "Files in target/release before renaming"
ls -la .
mv libquery_engine.dylib libquery_engine.dylib.node
echo "Files in target/release after renaming"
ls -la .
- uses: actions/upload-artifact@v4
with:
name: binaries
name: darwin-arm64
path: |
${{ github.workspace }}/target/aarch64-apple-darwin/release/schema-engine
${{ github.workspace }}/target/aarch64-apple-darwin/release/prisma-fmt
${{ github.workspace }}/target/aarch64-apple-darwin/release/query-engine
${{ github.workspace }}/target/aarch64-apple-darwin/release/libquery_engine.dylib
${{ github.workspace }}/target/aarch64-apple-darwin/release/libquery_engine.dylib.node
202 changes: 202 additions & 0 deletions .github/workflows/build-engines-linux-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
name: Build Engines for Linux

on:
workflow_call:
inputs:
commit:
description: 'Commit on the given branch to build'
type: string
required: false

jobs:
build:
name: '${{ matrix.target.name }} for commit ${{ inputs.commit }}'
runs-on: ubuntu-22.04

strategy:
fail-fast: false
matrix:
# ⚠️ The target names are used to dtermine the directory name when uploaded to the buckets.
# Do not change them.
target:
# Linux Glibc
- name: 'rhel-openssl-1.0.x'
image: 'prismagraphql/build:rhel-libssl1.0.x'
target_string: ''
target_path: ''
features_string: '--features vendored-openssl'
- name: 'rhel-openssl-1.1.x'
image: 'prismagraphql/build:rhel-libssl1.1.x'
target_string: ''
target_path: ''
features_string: ''
- name: 'rhel-openssl-3.0.x'
image: 'prismagraphql/build:rhel-libssl3.0.x'
target_string: ''
target_path: ''
features_string: ''
# Linux Musl
# A better name would be "linux-musl-openssl-1.1.x"
# But we keep the old name for compatibility reasons
- name: 'linux-musl'
image: 'prismagraphql/build:alpine-libssl1.1.x'
target_string: ''
target_path: ''
features_string: ''
- name: 'linux-musl-openssl-3.0.x'
image: 'prismagraphql/build:alpine-libssl3.0.x'
target_string: ''
target_path: ''
features_string: ''
# Linux Static x86_64
# Note that the name should have "-static-"
# Because we look for "-static-" later in the construct_build_command step
- name: 'linux-static-x64'
image: 'prismagraphql/build:linux-static-x64'
target_string: '--target x86_64-unknown-linux-musl'
target_path: 'x86_64-unknown-linux-musl'
features_string: '--features vendored-openssl'
# Linux Glibc ARM64
- name: 'linux-arm64-openssl-1.0.x'
image: 'prismagraphql/build:cross-linux-arm-ssl-1.0.x'
target_string: '--target aarch64-unknown-linux-gnu'
target_path: 'aarch64-unknown-linux-gnu'
features_string: '--features vendored-openssl'
- name: 'linux-arm64-openssl-1.1.x'
image: 'prismagraphql/build:cross-linux-arm-ssl-1.1.x'
target_string: '--target aarch64-unknown-linux-gnu'
target_path: 'aarch64-unknown-linux-gnu'
features_string: ''
- name: 'linux-arm64-openssl-3.0.x'
image: 'prismagraphql/build:cross-linux-arm-ssl-3.0.x'
target_string: '--target aarch64-unknown-linux-gnu'
target_path: 'aarch64-unknown-linux-gnu'
features_string: ''
# Linux Musl ARM64
- name: 'linux-musl-arm64-openssl-1.1.x'
image: 'prismagraphql/build:cross-linux-musl-arm-ssl-1.1.x'
target_string: '--target aarch64-unknown-linux-musl'
target_path: 'aarch64-unknown-linux-musl'
features_string: ''
- name: 'linux-musl-arm64-openssl-3.0.x'
image: 'prismagraphql/build:cross-linux-musl-arm-ssl-3.0.x'
target_string: '--target aarch64-unknown-linux-musl'
target_path: 'aarch64-unknown-linux-musl'
features_string: ''
# Linux Static ARM64
# Note that the name should have "-static-"
# Because we look for "-static-" later in the construct_build_command step
- name: 'linux-static-arm64'
image: 'prismagraphql/build:linux-static-arm64'
target_string: '--target aarch64-unknown-linux-musl'
target_path: 'aarch64-unknown-linux-musl'
features_string: '--features vendored-openssl'

steps:
- name: Output link to commit
if: ${{ inputs.commit }}
run: echo https://github.com/prisma/prisma-engines/commit/${{ inputs.commit }}

- name: Checkout ${{ inputs.commit }}
uses: actions/checkout@v4
with:
ref: ${{ inputs.commit }}

- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-

- name: Construct build command
id: construct_build_command
env:
TARGET_NAME: ${{ matrix.target.name }}
IMAGE: ${{ matrix.target.image }}
TARGET_STRING: ${{ matrix.target.target_string }}
FEATURES_STRING: ${{ matrix.target.features_string }}
run: |
set -eux;
command=$(bash .github/workflows/utils/constructDockerBuildCommand.sh)
# store command in GitHub output
echo "COMMAND=$command" >> "$GITHUB_OUTPUT"
- name: Show Build Command
env:
COMMAND: ${{ steps.construct_build_command.outputs.COMMAND }}"
run: echo "Build command is $COMMAND"

- name: Execute Build command
run: ${{ steps.construct_build_command.outputs.command }}

- name: Prepare files for "release" target
if: ${{ matrix.target.target_path == '' }}
env:
TARGET_NAME: ${{ matrix.target.name }}
RELEASE_DIR: ${{ github.workspace }}/target/release
run: |
echo "Files in target/release before renaming"
ls -la $RELEASE_DIR
echo "Copying files to engines-artifacts"
cp -r $RELEASE_DIR/ engines-artifacts
echo "Rename libquery_engine.so to libquery_engine.so.node for non-static targets"
if [[ "$TARGET_NAME" == *-static-* ]]; then
echo "Current target is static. Skipping."
else
mv engines-artifacts/libquery_engine.so engines-artifacts/libquery_engine.so.node
fi
echo "Files in engines-artifacts after renaming"
ls -la engines-artifacts
- name: Upload artifacts for "release" target
uses: actions/upload-artifact@v4
if: ${{ matrix.target.target_path == '' }}
with:
name: '${{ matrix.target.name }}'
path: |
${{ github.workspace }}/engines-artifacts/libquery_engine.so.node
${{ github.workspace }}/engines-artifacts/schema-engine
${{ github.workspace }}/engines-artifacts/query-engine
${{ github.workspace }}/engines-artifacts/prisma-fmt
- name: Prepare files for "${{ matrix.target.name }}" target
if: ${{ matrix.target.target_path != '' }}
env:
TARGET_NAME: ${{ matrix.target.name }}
RELEASE_DIR: ${{ github.workspace }}/target/${{ matrix.target.target_path }}/release
run: |
echo "Files in target/release before renaming"
ls -la $RELEASE_DIR
echo "Copying files to engines-artifacts"
cp -r $RELEASE_DIR/ engines-artifacts
echo "Rename libquery_engine.so to libquery_engine.so.node for non-static targets"
if [[ "$TARGET_NAME" == *-static-* ]]; then
echo "Current target is static. Skipping."
else
mv engines-artifacts/libquery_engine.so engines-artifacts/libquery_engine.so.node
fi
echo "Files in engines-artifacts after renaming"
ls -la engines-artifacts
- name: Upload artifacts for "${{ matrix.target.name }}" target
uses: actions/upload-artifact@v4
if: ${{ matrix.target.target_path != '' }}
with:
name: ${{ matrix.target.name }}
path: |
${{ github.workspace }}/engines-artifacts/libquery_engine.so.node
${{ github.workspace }}/engines-artifacts/schema-engine
${{ github.workspace }}/engines-artifacts/query-engine
${{ github.workspace }}/engines-artifacts/prisma-fmt
Loading

0 comments on commit f66d888

Please sign in to comment.