forked from conda/constructor
-
Notifications
You must be signed in to change notification settings - Fork 1
220 lines (215 loc) · 8.27 KB
/
main.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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
name: Build
on:
push:
branches:
- main
tags:
- "*"
pull_request:
branches:
- main
concurrency:
# Concurrency group that uses the workflow name and PR number if available
# or commit SHA as a fallback. If a new build is triggered under that
# concurrency group while a previous build is running it will be canceled.
# Repeated pushes to a PR will cancel all previous builds, while multiple
# merges to main will not cancel.
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
package:
name: ${{ matrix.os }}, Python ${{ matrix.pyver }}, ${{ matrix.micromamba && 'micromamba' || 'conda-standalone' }}
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os: [macos, ubuntu, windows]
pyver: ["3.7", "3.8", "3.9", "3.10"]
include:
- os: ubuntu
pyver: "3.9"
micromamba: true
- os: macos
pyver: "3.10"
micromamba: true
# Re-enable once micromamba supports menu creation
# - os: windows
# pyver: "3.8"
# micromamba: true
env:
PYTHONUNBUFFERED: True
steps:
- name: Print github context
run: |
echo "EVENT_NAME:" "$GITHUB_EVENT_NAME"
echo " REF:" "$GITHUB_REF"
echo " HEAD_REF:" "$GITHUB_HEAD_REF"
echo " BASE_REF:" "$GITHUB_BASE_REF"
echo " SHA:" "$GITHUB_SHA"
- name: Set temp dirs correctly
if: startsWith(matrix.os, 'windows')
# https://github.com/actions/virtual-environments/issues/712
shell: powershell
run: |
echo "TMPDIR=$env:USERPROFILE\AppData\Local\Temp" >> $env:GITHUB_ENV
echo "TEMP=$env:USERPROFILE\AppData\Local\Temp" >> $env:GITHUB_ENV
echo "TMP=$env:USERPROFILE\AppData\Local\Temp" >> $env:GITHUB_ENV
- name: Retrieve the source code
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Build the build environment
run: |
source $CONDA/etc/profile.d/conda.sh
[ $RUNNER_OS == macOS ] && export CONDA_PKGS_DIRS=~/.pkgs
conda create -p ../conda conda-build conda-verify
- name: Build the package
env:
PYTHONIOENCODING: utf-8
# Uncomment to run within conda build
# RUN_EXAMPLES: "1"
run: |
source $CONDA/etc/profile.d/conda.sh
conda activate ../conda
export CODECOV_COMMIT=$(git rev-parse --verify HEAD)
CODECOV_FOLDER=${PWD} \
CONDA_BLD_PATH="${{ runner.temp }}/conda-bld" \
conda build conda.recipe --python=${{ matrix.pyver }}
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: unit
- name: Upload the packages as artifact
if: github.event_name == 'push'
uses: actions/upload-artifact@v3
with:
# By uploading to the same artifact we can download all of the packages
# and upload them all to anaconda.org in a single job
name: package-${{ github.sha }}
path: ${{ runner.temp }}/conda-bld/*/*.tar.bz2
- name: Install local constructor
run: |
source $CONDA/etc/profile.d/conda.sh
CONDA_BLD_PATH="${{ runner.temp }}/conda-bld" \
conda create -n constructor -c local --strict-channel-priority constructor coverage
conda activate constructor
set -x
installed_channel=$(conda list constructor --json | jq -r '.[].channel')
if [[ "$installed_channel" != "conda-bld" ]]; then
echo $(conda list constructor --json)
echo "Installed constructor is not local!"
exit 1
fi
constructor --version
constructor --help-construct
- name: Update to NSIS logging builds on Windows
if: startsWith(matrix.os, 'windows')
run: |
source $CONDA/etc/profile.d/conda.sh
conda activate constructor
conda install -y "conda-forge::nsis=*=*_log_*"
echo "NSIS_USING_LOG_BUILD=1" >> $GITHUB_ENV
- name: Generate self-signed certificate (Windows)
if: startsWith(matrix.os, 'windows')
shell: cmd
run: |
set "CONSTRUCTOR_SIGNING_CERTIFICATE=${{ runner.temp }}\certificate.pfx"
set "CONSTRUCTOR_PFX_CERTIFICATE_PASSWORD=1234"
powershell scripts\create_self_signed_certificate.ps1
copy /Y "%CONSTRUCTOR_SIGNING_CERTIFICATE%" examples\signing\certificate.pfx
:: Careful with the trailing spaces before the >> redirect!
echo CONSTRUCTOR_PFX_CERTIFICATE_PASSWORD=1234>> %GITHUB_ENV%
echo CONSTRUCTOR_SIGNTOOL_PATH=C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x86\signtool.exe>> %GITHUB_ENV%
- name: Set up conda executable
run: |
source $CONDA/etc/profile.d/conda.sh
if [[ "${{ matrix.micromamba }}" != "" ]]; then
conda create -yqp ./micromamba -c conda-forge micromamba
if [[ ${{ matrix.os }} == "windows" ]]; then
echo "CONSTRUCTOR_CONDA_EXE=./micromamba/Library/bin/micromamba.exe" >> $GITHUB_ENV
else
echo "CONSTRUCTOR_CONDA_EXE=./micromamba/bin/micromamba" >> $GITHUB_ENV
fi
else
conda activate constructor
echo "CONSTRUCTOR_CONDA_EXE=$CONDA_PREFIX/standalone_conda/conda.exe" >> $GITHUB_ENV
fi
- name: Run examples and prepare artifacts
run: |
rm -rf coverage.json
source $CONDA/etc/profile.d/conda.sh
conda activate constructor
mkdir -p examples_artifacts/
python scripts/run_examples.py \
--keep-artifacts=examples_artifacts/ \
--conda-exe="${CONSTRUCTOR_CONDA_EXE}"
coverage json
- name: Test with conda-libmamba-solver
run: |
source $CONDA/etc/profile.d/conda.sh
conda activate constructor
conda install -yq conda-libmamba-solver
conda list
CONDA_SOLVER=libmamba CONDA_VERBOSITY=1 constructor examples/noconda/ --output-dir=examples_artifacts/
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: integration
- name: Upload the example installers as artifacts
if: github.event_name == 'pull_request' && matrix.pyver == '3.9'
uses: actions/upload-artifact@v3
with:
name: installers-${{ runner.os }}-${{ github.sha }}-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}
path: examples_artifacts/
retention-days: 7
upload:
needs: package
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- name: Retrieve the source code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Download the build artifacts
uses: actions/download-artifact@v3
with:
name: package-${{ github.sha }}
path: conda-bld
- name: Install conda packages
run: |
source $CONDA/bin/activate
conda install -y sphinx anaconda-client
- name: Upload to anaconda.org
env:
ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
GITHUB_REF: ${{ github.ref }}
run: |
source $CONDA/bin/activate
[[ "$GITHUB_REF" =~ ^refs/tags/ ]] || export LABEL="--label dev"
anaconda --verbose --token $ANACONDA_TOKEN upload --user ctools $LABEL conda-bld/*/*.tar.bz2 --force
docs:
name: Check docs are up-to-date
runs-on: ubuntu-latest
steps:
- name: Retrieve the source code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install local constructor
run: |
source $CONDA/bin/activate
conda create -n constructor constructor jinja2
conda activate constructor
pip install -U . --no-deps
- name: Build docs
run: |
source $CONDA/bin/activate
conda activate constructor
set -ex
python scripts/make_docs.py
git diff --exit-code