forked from sagemath/sage
-
Notifications
You must be signed in to change notification settings - Fork 0
151 lines (142 loc) · 6.01 KB
/
cygwin.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
name: Reusable workflow for Cygwin
on:
workflow_call:
inputs:
targets_pre:
default: build/make/Makefile
type: string
targets:
type: string
targets_optional:
default: build/make/Makefile
type: string
prefix:
required: false
default: /opt/sage
type: string
toxenv:
required: false
default: local-cygwin-choco-standard
type: string
#
# For use in multi-stage CIs
#
stage:
required: false
default: main
type: string
previous_stages:
required: false
type: string
#
# For use in upstream CIs
#
upstream_artifact:
required: false
type: string
sage_repo:
required: false
type: string
sage_trac_git:
required: false
type: string
sage_trac_ticket:
required: false
type: string
sage_ref:
required: false
type: string
jobs:
stage:
env:
MAKE: make -j8
SAGE_NUM_THREADS: 3
CYGWIN: winsymlinks:native
EXTRA_CONFIGURE_ARGS: --enable-fat-binary
SAGE_LOCAL: ${{ inputs.prefix }}-${{ github.sha }}
LOCAL_ARTIFACT_NAME: sage-local-commit-${{ github.sha }}-${{ inputs.toxenv }}
LOGS_ARTIFACT_NAME: logs-commit-${{ github.sha }}-${{ inputs.toxenv }}
runs-on: windows-latest
steps:
- run: |
git config --global core.autocrlf false
git config --global core.symlinks true
- name: install cygwin with choco
shell: bash {0}
run: |
choco --version
choco install git python39 python39-pip --source cygwin
- name: Check out SageMath
uses: actions/checkout@v4
with:
repository: ${{ inputs.sage_repo }}
ref: ${{ inputs.sage_ref }}
fetch-depth: 2000
- name: Check out git-trac-command
uses: actions/checkout@v4
with:
repository: sagemath/git-trac-command
path: git-trac-command
if: inputs.sage_trac_git != ''
- name: Check out SageMath from trac.sagemath.org
shell: bash {0}
# Random sleep and retry to limit the load on trac.sagemath.org
run: |
git config --global user.email "ci-sage@example.com"
git config --global user.name "ci-sage workflow"
if [ ! -d .git ]; then git init; fi; git remote add trac ${{ inputs.sage_trac_git }} && x=1 && while [ $x -le 5 ]; do x=$(( $x + 1 )); sleep $(( $RANDOM % 60 + 1 )); if git-trac-command/git-trac fetch ${{ inputs.sage_trac_ticket }}; then git merge FETCH_HEAD || echo "(ignored)"; exit 0; fi; sleep 40; done; exit 1
if: inputs.sage_trac_git != ''
- name: Download upstream artifact
uses: actions/download-artifact@v3
with:
path: upstream
name: ${{ inputs.upstream_artifact }}
if: inputs.upstream_artifact
- name: Update Sage packages from upstream artifact
run: |
C:\\tools\\cygwin\\bin\\bash -l -c 'cd $(cygpath -u "$GITHUB_WORKSPACE") && git config --global --add safe.directory $(pwd) && ls -l upstream/ && export PATH="$(pwd)/build/bin:$PATH:/usr/local/bin:/usr/bin" && (cd upstream && bash -x update-pkgs.sh) && git diff'
if: inputs.upstream_artifact
- name: Download sage-local artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.LOCAL_ARTIFACT_NAME }}
path: C:\\tools\\cygwin\\tmp
if: inputs.previous_stages
- name: Extract sage-local artifact
run: |
C:\\tools\\cygwin\\bin\\dash -l -c 'cd $(cygpath -u "$GITHUB_WORKSPACE") && .github/workflows/extract-sage-local.sh /tmp/sage-local-*.tar && tar --create --listed-incremental=/tmp/sage-local.snar --file /dev/null "${{ env.SAGE_LOCAL }}"'
if: inputs.previous_stages
- name: tox
run: |
C:\\tools\\cygwin\\bin\\bash -l -x -c 'cat /proc/cpuinfo'
C:\\tools\\cygwin\\bin\\bash -l -x -c 'python3.9 -m pip install tox'
C:\\tools\\cygwin\\bin\\bash -l -x -c 'cd $(cygpath -u "$GITHUB_WORKSPACE") && PREFIX="${{ env.SAGE_LOCAL }}" TARGETS_PRE="${{ inputs.targets_pre }}" TARGETS_OPTIONAL="${{ inputs.targets_optional }}" tox -e ${{ inputs.toxenv }} -- ${{ inputs.targets }}'
- name: Prepare logs artifact
run: |
C:\\tools\\cygwin\\bin\\bash -l -c 'cd $(cygpath -u "$GITHUB_WORKSPACE") && mkdir -p "artifacts/$LOGS_ARTIFACT_NAME"; for a in "${{ env.SAGE_LOCAL }}"/var/tmp/sage/build/*; do if [ -d "$a" ]; then tar -c --remove-files -f "artifacts/$LOGS_ARTIFACT_NAME/"$(basename "$a")".tar" "$a"; fi; done; cp -r logs/* "artifacts/$LOGS_ARTIFACT_NAME"'
if: always()
- uses: actions/upload-artifact@v3
with:
path: artifacts
name: ${{ env.LOGS_ARTIFACT_NAME }}
if: always()
- name: Print out logs for immediate inspection
# The markup in the output is a GitHub Actions logging command
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/development-tools-for-github-actions
shell: bash
run: |
find "artifacts/$LOGS_ARTIFACT_NAME" -type f -name "*.log" -exec sh -c 'if tail -20 "{}" 2>/dev/null | grep "^Error" >/dev/null; then echo :":"error file={}:":" ==== LOG FILE {} CONTAINS AN ERROR ====; cat {} ; fi' \;
if: always()
- name: Prepare sage-local artifact
# We specifically use the cygwin tar so that symlinks are saved/restored correctly on Windows.
# We remove the $SAGE_LOCAL/lib64 link, which will be recreated by the next stage.
run: |
C:\\tools\\cygwin\\bin\\bash -l -c 'cd $(cygpath -u "$GITHUB_WORKSPACE") && rm -f "${{ env.SAGE_LOCAL }}"/lib64; tar -cf /tmp/sage-local-${{ inputs.stage }}.tar --listed-incremental=/tmp/sage-local.snar "${{ env.SAGE_LOCAL }}"'
if: always()
- uses: actions/upload-artifact@v3
# upload-artifact@v2 does not support whitespace in file names.
# so we tar up the directory ourselves
with:
path: C:\\tools\\cygwin\\tmp\\sage-local-${{ inputs.stage }}.tar
name: ${{ env.LOCAL_ARTIFACT_NAME }}
if: always()