Repository navigation
141 lines (141 loc) · 7.2 KB
/
Copy pathportability-release.yml
File metadata and controls
141 lines (141 loc) · 7.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Portability package
on:
pull_request:
paths:
- components/portability/**
- scripts/scheduling_release.py
- tests/test_scheduling_release.py
- .github/workflows/portability-release.yml
workflow_dispatch:
inputs:
revision:
description: Full merged main commit SHA containing the portability source to publish
required: true
type: string
permissions:
contents: read
concurrency:
group: portability-package-${{ github.event_name == 'workflow_dispatch' && 'publication' || github.ref }}
cancel-in-progress: false
jobs:
build:
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
outputs:
revision: ${{ steps.selection.outputs.revision }}
version: ${{ steps.selection.outputs.version }}
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
fetch-depth: 0
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: '3.13'
- uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6
with:
enable-cache: false
- name: Select exact source and qualify publication controls
id: selection
env:
SELECTED_REVISION: ${{ inputs.revision || github.sha }}
EVENT_NAME: ${{ github.event_name }}
run: |
flags=()
if [ "$EVENT_NAME" = pull_request ]; then flags+=(--qualification); fi
python scripts/scheduling_release.py plan --component portability --revision "$SELECTED_REVISION" "${flags[@]}" --output "$GITHUB_OUTPUT"
uv run --no-project --with 'pytest>=8' python -m pytest -q tests/test_scheduling_release.py
- name: Build once from selected standalone source
env:
SELECTED_REVISION: ${{ steps.selection.outputs.revision }}
EVENT_NAME: ${{ github.event_name }}
run: |
mkdir "$RUNNER_TEMP/portability-source"
git archive "$SELECTED_REVISION" components/portability | tar -x -C "$RUNNER_TEMP/portability-source"
uv build --sdist --wheel --out-dir "$RUNNER_TEMP/portability-dist" "$RUNNER_TEMP/portability-source/components/portability"
rm -f "$RUNNER_TEMP/portability-dist/.gitignore" # uv output sentinel, not a release asset.
flags=()
if [ "$EVENT_NAME" = pull_request ]; then flags+=(--qualification); fi
python scripts/scheduling_release.py seal --component portability --revision "$SELECTED_REVISION" --dist "$RUNNER_TEMP/portability-dist" "${flags[@]}"
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: portability-distributions
path: ${{ runner.temp }}/portability-dist/*
if-no-files-found: error
installed:
needs: build
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
fetch-depth: 0
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: '3.13'
- uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6
with:
enable-cache: false
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
name: portability-distributions
path: ${{ runner.temp }}/portability-dist
- name: Retrieve the exact public worktrees dependency
env:
GH_TOKEN: ${{ github.token }}
SELECTED_REVISION: ${{ needs.build.outputs.revision }}
run: |
git show "$SELECTED_REVISION:components/portability/worktrees-source.json" > "$RUNNER_TEMP/selected-worktrees-source.json"
dependency_tag=$(python -c 'import json,sys; print(json.load(open(sys.argv[1]))["tag"])' "$RUNNER_TEMP/selected-worktrees-source.json")
dependency_revision=$(python -c 'import json,sys; print(json.load(open(sys.argv[1]))["revision"])' "$RUNNER_TEMP/selected-worktrees-source.json")
mkdir "$RUNNER_TEMP/worktrees-dist"
gh release download "$dependency_tag" --repo microsoft/amplifier-unified --dir "$RUNNER_TEMP/worktrees-dist"
cmp "$RUNNER_TEMP/selected-worktrees-source.json" "$RUNNER_TEMP/worktrees-dist/worktrees-source.json"
python scripts/scheduling_release.py verify --component worktrees --revision "$dependency_revision" --dist "$RUNNER_TEMP/worktrees-dist"
- name: Verify original bytes and test the installed wheel outside checkout
env:
SELECTED_REVISION: ${{ needs.build.outputs.revision }}
PACKAGE_VERSION: ${{ needs.build.outputs.version }}
EVENT_NAME: ${{ github.event_name }}
run: |
flags=()
if [ "$EVENT_NAME" = pull_request ]; then flags+=(--qualification); fi
python scripts/scheduling_release.py verify --component portability --revision "$SELECTED_REVISION" --dist "$RUNNER_TEMP/portability-dist" "${flags[@]}"
uv venv --python 3.13 "$RUNNER_TEMP/portability-installed"
python_path="$RUNNER_TEMP/portability-installed/bin/python"
uv pip install --python "$python_path" "$RUNNER_TEMP"/worktrees-dist/amplifier_worktrees-*-py3-none-any.whl "$RUNNER_TEMP/portability-dist/amplifier_portability-$PACKAGE_VERSION-py3-none-any.whl[test]"
mkdir "$RUNNER_TEMP/portability-tests"
git archive "$SELECTED_REVISION:components/portability" tests | tar -x -C "$RUNNER_TEMP/portability-tests"
cd "$RUNNER_TEMP/portability-tests"
"$python_path" -I -c 'from pathlib import Path; import sys,amplifier_portability,amplifier_worktrees; assert all(Path(package.__file__).resolve().is_relative_to(Path(sys.prefix).resolve()) for package in (amplifier_portability,amplifier_worktrees))'
"$python_path" -I -m pytest -q tests --junitxml=installed-tests.xml
uv pip check --python "$python_path"
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
if: always()
with:
name: portability-installed-linux
path: ${{ runner.temp }}/portability-tests/installed-tests.xml
if-no-files-found: error
publish:
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main'
needs: [build, installed]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
fetch-depth: 0
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: '3.13'
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
name: portability-distributions
path: ${{ runner.temp }}/portability-dist
- name: Publish or verify the exact component release without replacing the app latest
env:
GH_TOKEN: ${{ github.token }}
SELECTED_REVISION: ${{ needs.build.outputs.revision }}
run: python scripts/scheduling_release.py publish --component portability --revision "$SELECTED_REVISION" --dist "$RUNNER_TEMP/portability-dist"