This repository has been archived by the owner on May 30, 2024. It is now read-only.
forked from eirikb/proof-of-conan
-
Notifications
You must be signed in to change notification settings - Fork 0
177 lines (163 loc) · 6.95 KB
/
build-pr.yml
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
name: Build PR
on:
workflow_dispatch:
inputs:
repository:
required: true
default: 'conan-io/conan-center-index'
pr:
required: true
env:
GH_TOKEN: ${{ github.token }}
REPOSITORY: ${{ github.event.inputs.repository }}
PR: ${{ github.event.inputs.pr }}
CLICOLOR_FORCE: 1
FORCE_COLOR: 1
jobs:
find_modified_package:
name: Find modified package
runs-on: ubuntu-latest
outputs:
versions: ${{ steps.generate-matrix.outputs.versions }}
recipe_folder: ${{ steps.find-modified-package.outputs.recipe_folder }}
package_name: ${{ steps.find-modified-package.outputs.package_name }}
steps:
- name: find modified package
id: find-modified-package
run: |
gh pr view -R $REPOSITORY $PR --json files --jq '.files[].path' | while read file
do
if [[ $file != recipes/* ]]
then
echo file not in recipes: $file
continue
fi
IFS='/' read -ra my_array <<< "$file"
if [ "${#my_array[@]}" -lt 4 ]
then
echo file too short: $file
continue
fi
package_name=${my_array[1]}
recipe_folder=${my_array[2]}
echo package_name=$package_name
echo recipe_folder=$recipe_folder
echo "package_name=$package_name" >> "$GITHUB_OUTPUT"
echo "recipe_folder=$recipe_folder" >> "$GITHUB_OUTPUT"
break
done
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- run: pip3 install conan yq
- uses: actions/checkout@v4
with:
repository: ${{ github.event.inputs.repository }}
sparse-checkout: recipes/${{ steps.find-modified-package.outputs.package_name }}/config.yml
ref: refs/pull/${{ github.event.inputs.pr }}/merge
- name: find modified versions
id: generate-matrix
run: |
version_list=$(yq -c '[.versions | to_entries[] | select(.value.folder=="${{ steps.find-modified-package.outputs.recipe_folder }}").key]' recipes/${{ steps.find-modified-package.outputs.package_name }}/config.yml)
echo version_list=$version_list
echo "versions=$version_list" >> "$GITHUB_OUTPUT"
- run: |
echo "Building Pull request" >> $GITHUB_STEP_SUMMARY
echo "- repo: $REPOSITORY" >> $GITHUB_STEP_SUMMARY
echo "- PR: #$PR" >> $GITHUB_STEP_SUMMARY
echo "- package: ${{ steps.find-modified-package.outputs.package_name }}" >> $GITHUB_STEP_SUMMARY
echo "- recipe folder: ${{ steps.find-modified-package.outputs.recipe_folder }}" >> $GITHUB_STEP_SUMMARY
echo "- versions: ${{ steps.generate-matrix.outputs.versions }}" >> $GITHUB_STEP_SUMMARY
_:
runs-on: ${{ matrix.os }}
needs:
- find_modified_package
name: ${{ needs.find_modified_package.outputs.package_name }}/${{ matrix.version }} ${{ matrix.shared }} ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-11]
shared: ["True", "False"]
version: ${{ fromJSON(needs.find_modified_package.outputs.versions) }}
continue-on-error: true
env:
NOT_ON_C3I: 1
GH_TOKEN: ${{ github.token }}
REPOSITORY: ${{ github.event.inputs.repository }}
PR: ${{ github.event.inputs.pr }}
steps:
- uses: actions/checkout@v4
with:
repository: ${{ github.event.inputs.repository }}
sparse-checkout: recipes/${{ needs.find_modified_package.outputs.package_name }}/${{ needs.find_modified_package.outputs.recipe_folder }}
ref: refs/pull/${{ github.event.inputs.pr }}/merge
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- run: pip3 install conan yq
- name: set conan home
if: ${{ runner.os == 'Windows' }}
shell: bash
run: echo "CONAN_HOME=${{ runner.temp }}\\.c2" >> $GITHUB_ENV
- run: conan profile detect --force
shell: bash
- name: conan create
id: conan_create
shell: bash
env:
CONAN_SYSREQUIRES_MODE: enabled
run: |
echo "| os | shared | cppstd | version | result |" >> $GITHUB_STEP_SUMMARY
echo "| -- | ------ | ------ | ------- | ------ |" >> $GITHUB_STEP_SUMMARY
PROFILE_PATH=$(conan profile path default)
COMPILER=$(awk -F "=" '/^compiler=/ {print $2}' $PROFILE_PATH)
COMPILER_VERSION=$(awk -F "=" '/^compiler.version=/ {print $2}' $PROFILE_PATH)
echo "$PROFILE_PATH $COMPILER $COMPILER_VERSION"
CPP_STDS=$(curl https://github.com/conan-io/conan-center-index/raw/master/.c3i/config_v2.yml -L | yq -r -c .cppstd.\"$COMPILER\".\"$COMPILER_VERSION\"[])
for cpp_std in $CPP_STDS; do
cpp_std=$(echo $cpp_std | tr -d '[:space:]')
conan_command="-s:a compiler.cppstd=$cpp_std --version ${{ matrix.version }} recipes/${{ needs.find_modified_package.outputs.package_name }}/${{ needs.find_modified_package.outputs.recipe_folder }} -o */*:shared=${{ matrix.shared }} -c tools.system.package_manager:mode=install -c tools.system.package_manager:sudo=True"
set +e
conan create $conan_command 2> >(tee conan_output >&2)
code=${PIPESTATUS[0]}
set -e
echo $code
case $code in
0)
ICON=":white_check_mark:"
;;
6)
ICON=":arrow_right_hook:"
;;
1)
ICON=":x:"
;;
*)
ICON=":interrobang: $code"
;;
esac
if grep -Fq "conan graph explain" conan_output; then
conan graph explain $conan_command
fi
if grep -Fq "conan graph info" conan_output; then
conan graph info $conan_command --format=html >graph.html
fi
echo "| ${{ matrix.os }} | ${{ matrix.shared }} | $cpp_std | ${{ matrix.version }} | $ICON |" >> $GITHUB_STEP_SUMMARY
if [ $code -ne 6 ]; then
exit "$code"
fi
done
exit 0
- uses: actions/upload-artifact@v4
if: ${{ failure() && steps.conan_create.conclusion == 'failure' }}
with:
name: graph_${{ needs.find_modified_package.outputs.package_name }}_${{ matrix.version }}_${{ matrix.shared }}_${{ matrix.os }}
path: graph.html
if-no-files-found: ignore
Post_Result:
name: Post results
needs: [_]
runs-on: ubuntu-latest
if: ${{ !cancelled() }}
steps:
- run: GH_TOKEN=${{ secrets.GH_TOKEN }} gh issue comment -R $REPOSITORY $PR -b "The build is now finished. You can take a look at the results [here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }})"