Skip to content

Commit 21a4c90

Browse files
committed
Refactor package build workflow
* Merge llvmdev_win_builder.yml + llvmdev_win-64_conda_builder.yml into one to avoid code duplication * Add input parameter to be able to select between recipes to build * Rename flow to llvmdev_conda_builder.yml as it contains nothing specific to windows and the code is just a generic conda package builder * Add ${{ matrix.recipe }}-${{ runner.os }} to upload name to better differentiate artifacts * Remove "x" from `bash -elx {0}` as that pollutes the Action log due to the implicit `source "$CONDA/etc/profile.d/conda.sh` calls in every step. * Set `run-post: false` to avoid setup-miniconda cleaning up the Github Action VM as that is wiped after the run anyways * Run the flow if it gets changed in PRs, to see a public verfication that the changes are actually working
1 parent 0924039 commit 21a4c90

File tree

5 files changed

+177
-147
lines changed

5 files changed

+177
-147
lines changed

.github/workflows/llvmdev_build.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
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: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
38+
cancel-in-progress: true
39+
40+
jobs:
41+
42+
check:
43+
runs-on: ubuntu-24.04
44+
outputs:
45+
matrix: ${{ steps.evaluate.outputs.matrix }}
46+
steps:
47+
- uses: actions/checkout@v4
48+
- uses: actions/setup-python@v5
49+
with:
50+
python-version: '3.13'
51+
- name: Evaluate
52+
id: evaluate
53+
env:
54+
GITHUB_EVENT_NAME: ${{ github.event_name }}
55+
GITHUB_LABEL_NAME: ${{ github.event.label.name }}
56+
GITHUB_WORKFLOW_INPUT: ${{ toJson(github.event.inputs) }}
57+
run: |
58+
./buildscripts/github/llvmdev_evaluate.py
59+
60+
build:
61+
needs: check
62+
name: ${{ matrix.recipe }}-${{ matrix.platform }}
63+
runs-on: ${{ matrix.runner }}
64+
defaults:
65+
run:
66+
shell: bash -el {0}
67+
strategy:
68+
matrix: ${{fromJson(needs.check.outputs.matrix)}}
69+
fail-fast: false
70+
71+
steps:
72+
- name: Clone repository
73+
uses: actions/checkout@v4
74+
75+
- name: Setup Miniconda
76+
uses: conda-incubator/setup-miniconda@v3
77+
with:
78+
auto-update-conda: true
79+
auto-activate-base: true
80+
activate-environment: ''
81+
run-post: false
82+
83+
- name: Install conda-build
84+
run: |
85+
conda install conda-build
86+
87+
- name: Build conda package
88+
env:
89+
CONDA_CHANNEL_DIR: conda_channel_dir
90+
run: |
91+
set -x
92+
mkdir "${CONDA_CHANNEL_DIR}"
93+
conda build "./conda-recipes/${{ matrix.recipe }}" "--output-folder=${CONDA_CHANNEL_DIR}"
94+
ls -lah "${CONDA_CHANNEL_DIR}"
95+
96+
- name: Upload conda package
97+
uses: actions/upload-artifact@v4
98+
with:
99+
name: ${{ matrix.recipe }}-${{ runner.platform }}
100+
path: conda_channel_dir
101+
compression-level: 0
102+
retention-days: 7
103+
if-no-files-found: error
104+
105+
- name: Get Workflow Run ID
106+
run: |
107+
echo "Current workflow run ID: ${{ github.run_id }}"
108+
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: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/usr/bin/env python
2+
3+
import json
4+
import os
5+
6+
event = os.environ.get("GITHUB_EVENT_NAME")
7+
label = os.environ.get("GITHUB_LABEL_NAME")
8+
inputs = os.environ.get("GITHUB_WORKFLOW_INPUT")
9+
10+
runner_mapping = {
11+
"linux-64": "ubuntu-24.04",
12+
"linux-aarch64": "ubuntu-24.04-arm",
13+
"osx-64": "macos-13",
14+
"osx-arm64": "macos-14",
15+
"win-64": "windows-2019",
16+
}
17+
18+
default_include = [
19+
{ "runner": runner_mapping["linux-64"],
20+
"platform": "linux-64",
21+
"recipe": "llvmdev"},
22+
{
23+
"runner": runner_mapping["linux-aarch64"],
24+
"platform": "linux-aarch64",
25+
"recipe": "llvmdev",
26+
},
27+
{
28+
"runner": runner_mapping["osx-arm64"],
29+
"platform": "osx-arm64",
30+
"recipe": "llvmdev",
31+
},
32+
{
33+
"runner": runner_mapping["osx-arm64"],
34+
"platform": "osx-arm64",
35+
"recipe": "llvmdev_manylinux",
36+
},
37+
{ "runner": runner_mapping["win-64"],
38+
"platform": "win-64",
39+
"recipe": "llvmdev"},
40+
{
41+
"runner": runner_mapping["win-64"],
42+
"platform": "win-64",
43+
"recipe": "llvmdev_manylinux",
44+
},
45+
]
46+
47+
print(
48+
f"event: '{event}', label: '{label}', inputs: '{inputs}', changed_files: '{changed_files}'"
49+
)
50+
51+
if event == "pull_request":
52+
# full matrix build
53+
include = default_include
54+
elif event == "label":
55+
# reduced matrix build
56+
include = default_include[0:1]
57+
elif event == "workflow_dispatch":
58+
# TBD
59+
include = {}
60+
else:
61+
include = {}
62+
matrix = {"include": include}
63+
64+
print(f"matrix:\n {json.dumps(matrix, indent=4)}")
65+
66+
#with open(os.environ["GITHUB_OUTPUT"], "a") as fh:
67+
# print(f"{matrix}={json.dumps(matrix)}", file=fh)
68+
69+
print(f"::set-output name=matrix::{json.dumps(matrix)}")

0 commit comments

Comments
 (0)