Skip to content

Commit abdc044

Browse files
committed
Refactor package build workflow
1 parent 0924039 commit abdc044

File tree

5 files changed

+187
-147
lines changed

5 files changed

+187
-147
lines changed

.github/workflows/llvmdev_build.yml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: llvmdev
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- .github/workflows/llvmdev_build.yml
7+
label:
8+
types: [created]
9+
workflow_dispatch:
10+
inputs:
11+
platform:
12+
description: Conda Platform
13+
default: linux-64
14+
required: true
15+
type: choice
16+
options:
17+
- linux-64
18+
- linux-aarch64
19+
- osx-64
20+
- osx-arm64
21+
- win-64
22+
recipe:
23+
description: Recipe to build
24+
default: llvmdev
25+
required: true
26+
type: choice
27+
options:
28+
- llvmdev
29+
- llvmdev_manylinux
30+
31+
concurrency:
32+
# Concurrency group that uses the workflow name and PR number if available
33+
# or commit SHA as a fallback. If a new build is triggered under that
34+
# concurrency group while a previous build is running it will be canceled.
35+
# Repeated pushes to a PR will cancel all previous builds, while multiple
36+
# merges to master will not cancel.
37+
group: >-
38+
${{ github.workflow }}-
39+
${{ github.event.pull_request.number
40+
|| toJson(github.event.inputs)
41+
|| github.event.label.name
42+
|| github.sha }}
43+
cancel-in-progress: true
44+
45+
jobs:
46+
47+
check:
48+
runs-on: ubuntu-24.04
49+
outputs:
50+
matrix: ${{ steps.evaluate.outputs.matrix }}
51+
steps:
52+
- uses: actions/checkout@v4
53+
- uses: actions/setup-python@v5
54+
with:
55+
python-version: '3.13'
56+
- name: Evaluate
57+
id: evaluate
58+
env:
59+
GITHUB_EVENT_NAME: ${{ github.event_name }}
60+
GITHUB_LABEL_NAME: ${{ github.event.label.name }}
61+
GITHUB_WORKFLOW_INPUT: ${{ toJson(github.event.inputs) }}
62+
run: |
63+
./buildscripts/github/llvmdev_evaluate.py
64+
65+
build:
66+
needs: check
67+
name: ${{ matrix.recipe }}-${{ matrix.platform }}
68+
runs-on: ${{ matrix.runner }}
69+
defaults:
70+
run:
71+
shell: bash -el {0}
72+
strategy:
73+
matrix: ${{fromJson(needs.check.outputs.matrix)}}
74+
fail-fast: false
75+
76+
steps:
77+
- name: Clone repository
78+
uses: actions/checkout@v4
79+
80+
- name: Setup Miniconda
81+
uses: conda-incubator/setup-miniconda@v3
82+
with:
83+
auto-update-conda: true
84+
auto-activate-base: true
85+
activate-environment: ''
86+
run-post: false
87+
88+
- name: Install conda-build
89+
run: |
90+
conda install conda-build
91+
92+
- name: Build conda package
93+
env:
94+
CONDA_CHANNEL_DIR: conda_channel_dir
95+
run: |
96+
set -x
97+
mkdir "${CONDA_CHANNEL_DIR}"
98+
conda build "./conda-recipes/${{ matrix.recipe }}" "--output-folder=${CONDA_CHANNEL_DIR}"
99+
ls -lah "${CONDA_CHANNEL_DIR}"
100+
101+
- name: Upload conda package
102+
uses: actions/upload-artifact@v4
103+
with:
104+
name: ${{ matrix.recipe }}-${{ matrix.platform }}
105+
path: conda_channel_dir
106+
compression-level: 0
107+
retention-days: 7
108+
if-no-files-found: error
109+
110+
- name: Get Workflow Run ID
111+
run: |
112+
echo "Current workflow run ID: ${{ github.run_id }}"
113+
echo "Use this ID when triggering llvmlite workflow"

.github/workflows/llvmdev_linux-64_conda_builder.yml

Lines changed: 0 additions & 49 deletions
This file was deleted.

.github/workflows/llvmdev_win-64_conda_builder.yml

Lines changed: 0 additions & 49 deletions
This file was deleted.

.github/workflows/llvmdev_win_builder.yml

Lines changed: 0 additions & 49 deletions
This file was deleted.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/usr/bin/env python
2+
3+
import json
4+
import os
5+
from pathlib import Path
6+
7+
8+
event = os.environ.get("GITHUB_EVENT_NAME")
9+
label = os.environ.get("GITHUB_LABEL_NAME")
10+
inputs = os.environ.get("GITHUB_WORKFLOW_INPUT", "{}")
11+
12+
runner_mapping = {
13+
"linux-64": "ubuntu-24.04",
14+
"linux-aarch64": "ubuntu-24.04-arm",
15+
"osx-64": "macos-13",
16+
"osx-arm64": "macos-14",
17+
"win-64": "windows-2019",
18+
}
19+
20+
default_include = [
21+
{ "runner": runner_mapping["linux-64"],
22+
"platform": "linux-64",
23+
"recipe": "llvmdev"
24+
},
25+
{
26+
"runner": runner_mapping["linux-aarch64"],
27+
"platform": "linux-aarch64",
28+
"recipe": "llvmdev",
29+
},
30+
{
31+
"runner": runner_mapping["osx-arm64"],
32+
"platform": "osx-arm64",
33+
"recipe": "llvmdev",
34+
},
35+
{
36+
"runner": runner_mapping["osx-arm64"],
37+
"platform": "osx-arm64",
38+
"recipe": "llvmdev_manylinux",
39+
},
40+
{ "runner": runner_mapping["win-64"],
41+
"platform": "win-64",
42+
"recipe": "llvmdev"
43+
},
44+
{
45+
"runner": runner_mapping["win-64"],
46+
"platform": "win-64",
47+
"recipe": "llvmdev_manylinux",
48+
},
49+
]
50+
51+
print(f"Deciding what to do based on event: '{event}', label: '{label}', inputs: '{inputs}'")
52+
if event == "pull_request":
53+
print("pull_request detected")
54+
include = default_include
55+
elif event == "label" and label == "build":
56+
print("build label detected")
57+
include = default_include
58+
elif event == "workflow_dispatch":
59+
print("workflow_dispatch detected")
60+
params = json.loads(inputs)
61+
include = [
62+
{
63+
"runner": runner_mapping[params.get("platform", "linux-64")],
64+
"platform": params.get("platform", "linux-64"),
65+
"recipe": params.get("recipe", "llvmdev"),
66+
}
67+
]
68+
else:
69+
include = {}
70+
71+
matrix = {"include": include}
72+
print(f"Emitting matrix:\n {json.dumps(matrix, indent=4)}")
73+
74+
Path(os.environ["GITHUB_OUTPUT"]).write_text(f"matrix={json.dumps(matrix)}")

0 commit comments

Comments
 (0)