Skip to content

Commit

Permalink
Refactor package build workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
dbast committed Feb 5, 2025
1 parent 0924039 commit abdc044
Show file tree
Hide file tree
Showing 5 changed files with 187 additions and 147 deletions.
113 changes: 113 additions & 0 deletions .github/workflows/llvmdev_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: llvmdev

on:
pull_request:
paths:
- .github/workflows/llvmdev_build.yml
label:
types: [created]
workflow_dispatch:
inputs:
platform:
description: Conda Platform
default: linux-64
required: true
type: choice
options:
- linux-64
- linux-aarch64
- osx-64
- osx-arm64
- win-64
recipe:
description: Recipe to build
default: llvmdev
required: true
type: choice
options:
- llvmdev
- llvmdev_manylinux

concurrency:
# Concurrency group that uses the workflow name and PR number if available
# or commit SHA as a fallback. If a new build is triggered under that
# concurrency group while a previous build is running it will be canceled.
# Repeated pushes to a PR will cancel all previous builds, while multiple
# merges to master will not cancel.
group: >-
${{ github.workflow }}-
${{ github.event.pull_request.number
|| toJson(github.event.inputs)
|| github.event.label.name
|| github.sha }}
cancel-in-progress: true

jobs:

check:
runs-on: ubuntu-24.04
outputs:
matrix: ${{ steps.evaluate.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Evaluate
id: evaluate
env:
GITHUB_EVENT_NAME: ${{ github.event_name }}
GITHUB_LABEL_NAME: ${{ github.event.label.name }}
GITHUB_WORKFLOW_INPUT: ${{ toJson(github.event.inputs) }}
run: |
./buildscripts/github/llvmdev_evaluate.py
build:
needs: check
name: ${{ matrix.recipe }}-${{ matrix.platform }}
runs-on: ${{ matrix.runner }}
defaults:
run:
shell: bash -el {0}
strategy:
matrix: ${{fromJson(needs.check.outputs.matrix)}}
fail-fast: false

steps:
- name: Clone repository
uses: actions/checkout@v4

- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
auto-activate-base: true
activate-environment: ''
run-post: false

- name: Install conda-build
run: |
conda install conda-build
- name: Build conda package
env:
CONDA_CHANNEL_DIR: conda_channel_dir
run: |
set -x
mkdir "${CONDA_CHANNEL_DIR}"
conda build "./conda-recipes/${{ matrix.recipe }}" "--output-folder=${CONDA_CHANNEL_DIR}"
ls -lah "${CONDA_CHANNEL_DIR}"
- name: Upload conda package
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.recipe }}-${{ matrix.platform }}
path: conda_channel_dir
compression-level: 0
retention-days: 7
if-no-files-found: error

- name: Get Workflow Run ID
run: |
echo "Current workflow run ID: ${{ github.run_id }}"
echo "Use this ID when triggering llvmlite workflow"
49 changes: 0 additions & 49 deletions .github/workflows/llvmdev_linux-64_conda_builder.yml

This file was deleted.

49 changes: 0 additions & 49 deletions .github/workflows/llvmdev_win-64_conda_builder.yml

This file was deleted.

49 changes: 0 additions & 49 deletions .github/workflows/llvmdev_win_builder.yml

This file was deleted.

74 changes: 74 additions & 0 deletions buildscripts/github/llvmdev_evaluate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/env python

import json
import os
from pathlib import Path


event = os.environ.get("GITHUB_EVENT_NAME")
label = os.environ.get("GITHUB_LABEL_NAME")
inputs = os.environ.get("GITHUB_WORKFLOW_INPUT", "{}")

runner_mapping = {
"linux-64": "ubuntu-24.04",
"linux-aarch64": "ubuntu-24.04-arm",
"osx-64": "macos-13",
"osx-arm64": "macos-14",
"win-64": "windows-2019",
}

default_include = [
{ "runner": runner_mapping["linux-64"],
"platform": "linux-64",
"recipe": "llvmdev"
},
{
"runner": runner_mapping["linux-aarch64"],
"platform": "linux-aarch64",
"recipe": "llvmdev",
},
{
"runner": runner_mapping["osx-arm64"],
"platform": "osx-arm64",
"recipe": "llvmdev",
},
{
"runner": runner_mapping["osx-arm64"],
"platform": "osx-arm64",
"recipe": "llvmdev_manylinux",
},
{ "runner": runner_mapping["win-64"],
"platform": "win-64",
"recipe": "llvmdev"
},
{
"runner": runner_mapping["win-64"],
"platform": "win-64",
"recipe": "llvmdev_manylinux",
},
]

print(f"Deciding what to do based on event: '{event}', label: '{label}', inputs: '{inputs}'")
if event == "pull_request":
print("pull_request detected")
include = default_include
elif event == "label" and label == "build":
print("build label detected")
include = default_include
elif event == "workflow_dispatch":
print("workflow_dispatch detected")
params = json.loads(inputs)
include = [
{
"runner": runner_mapping[params.get("platform", "linux-64")],
"platform": params.get("platform", "linux-64"),
"recipe": params.get("recipe", "llvmdev"),
}
]
else:
include = {}

matrix = {"include": include}
print(f"Emitting matrix:\n {json.dumps(matrix, indent=4)}")

Path(os.environ["GITHUB_OUTPUT"]).write_text(f"matrix={json.dumps(matrix)}")

0 comments on commit abdc044

Please sign in to comment.