-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
146 lines (136 loc) · 4.19 KB
/
Copy pathaction.yml
File metadata and controls
146 lines (136 loc) · 4.19 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
142
143
144
145
146
name: sane-workflows
description: "Run a set of actions using sane-workflows"
branding:
icon: wind
color: green
inputs:
id:
description: ID of workflow run, i.e. name
required : true
type : string
paths:
description: List of paths pointing to workflow(s)
required : true
type : array
# Everything else is optional
dry_run:
description: Enable dry-run of tests instead
required : false
type : boolean
default : false
host:
description: Specific host to run workflow as
required : false
type : string
default : ''
actions:
description: Actions list to run, mutually exclusive with actions_filter
required : false
type : string
default : '[]'
actions_filter:
description: Actions filter to run, mutually exclusive with actions
required : false
type : string
default : ''
args :
description: Additional args to pass to sane_runner
required : false
type : string
default : ''
patch:
description: One-time patch dict allowed for modification of workflow, need be
required : false
type : string
default : ''
upload :
description: Whether to upload logs as an artifact on failure
required : false
type : boolean
default : false
# Python environment management
cache:
description: Whether to cache the python virtual environment
required : false
type : boolean
default : false
cache_id:
description: Specific cache id to use, if not set the key will be inputs.id
required : false
type : string
default : ''
venv:
description: Path to setup python virtual environment at
required : false
type : string
default : './venv/sane'
python_dependencies:
description: Extra python dependencies list needed for workflow
required : false
type : array
default : '[]'
upgrade:
description: Use pip install --upgrade when installing dependencies, not recommended with cache
required : false
type : boolean
default : true
runs:
using: "composite"
steps:
- if: ${{ inputs.cache == 'true' }}
name: Cache python environment
id: cache-venv
uses: actions/cache@v3
with:
path: |
${{ inputs.venv }}
key: venv-${{ inputs.cache_id || inputs.id }}
- if: ${{ inputs.cache == 'false' || steps.cache-venv.outputs.cache-hit != 'true' }}
name: Install sane-workflows
id : install-sane
shell: bash
run: |
if [ -x "${{ inputs.venv }}/bin/activate" ]; then
. ${{ inputs.venv }}/bin/activate
else
python3 -m venv ${{ inputs.venv }}
. ${{ inputs.venv }}/bin/activate
fi
python3 -m pip install --no-cache-dir ${{ inputs.upgrade && '--upgrade' }} sane-workflows
if [ "${{ inputs.python_dependencies }}" != "[]" ]; then
python3 -m pip install --no-cache-dir ${{ inputs.upgrade && '--upgrade' }} ${{ join( fromJson( inputs.python_dependencies ), ' ' ) }}
fi
- name: Run ${{ inputs.id }}
id : runTest
shell: bash
run: |
RUN_FLAG="-r"
if [ "${{ inputs.dry_run }}" = "true" ]; then
RUN_FLAG="-d"
fi
if [ ! -z "${{ inputs.action_filter }}" ]; then
ACTIONS="-f ${{ inputs.action_filter }}"
elif [ "${{ inputs.actions }}" != "[]" ]; then
ACTIONS="-a ${{ join( fromJson( inputs.actions ), ' ' ) }}"
fi
if [ ! -z "${{ inputs.host }}" ]; then
HOST="-sh ${{ inputs.host }}"
fi
if [ ! -z "${{ inputs.patch }}" ]; then
mkdir -p .patch-${{ inputs.id }}/
echo '{ "patches" : ${{ inputs.patch }} }' >> .patch-${{ inputs.id }}/patch.json
PATCH="-p .patch-${{ inputs.id }}/"
fi
. ${{ inputs.venv }}/bin/activate
sane_runner ${{ inputs.args }} $ACTIONS $HOST $PATCH \
-p ${{ join( fromJson( inputs.paths ), '-p ' ) }} \
-sl .${{ inputs.id }}_saves \
-ll ${{ inputs.id }}_logs \
$RUN_FLAG
- if : ${{ inputs.upload && failure() }}
name: Upload test logs
uses : actions/upload-artifact@v4
with:
name: ${{ inputs.id }}_logfiles
path: ${{ inputs.id }}_logs
include-hidden-files: true