Skip to content

Commit 8f14ea9

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 8f14ea9

File tree

5 files changed

+181
-147
lines changed

5 files changed

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

0 commit comments

Comments
 (0)