-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yaml
134 lines (118 loc) · 4.38 KB
/
action.yaml
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
name: 'Chaos Toolkit Run Workflow'
description: 'Run a Chaos Toolkit Experiment'
author: 'Chaos Toolkit'
branding:
icon: "loader"
color: "yellow"
inputs:
experiment-file:
description: "The path of the experiment to run relatove to the working directory"
required: true
default: "./experiment.json"
working-dir:
description: "The directory where the experiment will be run from"
required: false
default: "."
verbose:
description: "Make the run verbose"
required: false
default: "false"
install-dependencies:
description: "Specify the dependencies groups to install"
required: false
default: ""
dependencies-file:
description: "Specify a file containing your own Python dependencies to be also installed"
required: false
default: ""
python-version:
description: "The python version to use"
required: false
default: "3.11"
upload-results-as-artifacts:
description: "Upload Chaos Toolkit results (logs and journal) as job artifacts"
required: false
default: "true"
result-artifact-name:
description: "Name of the artifact file uploaded to the job"
required: false
default: "chaostoolkit-results"
github-token:
description: "The GitHub token to commit the results"
required: false
default: ${{ github.token }}
runs:
using: "composite"
steps:
- name: Fetch Dependencies Lock
shell: bash
run: |
echo "Fetch lock files for Chaos Tooklkit"
curl -o pdm.lock --silent https://raw.githubusercontent.com/chaostoolkit/run-action/main/pdm.lock
curl -o pyproject.toml --silent https://raw.githubusercontent.com/chaostoolkit/run-action/main/pyproject.toml
- name: Set up the Python Package Manager
uses: pdm-project/setup-pdm@v4
with:
python-version: ${{ inputs.python-version }}
cache: true
prerelease: false
- name: Install Chaos Toolkit
shell: bash
run: |
echo "Install Chaos Toolkit"
pdm sync --prod --no-editable --no-self --fail-fast --without gcp --without aws --without k8s --without slack --without otel
- name: Install Chaos Toolkit Dependencies (if requested)
shell: bash
run: |
if [ -n "${{ inputs.install-dependencies }}" ]; then
IFS=';' read -ra GROUP <<< "${{ inputs.install-dependencies }}"
for group in "${GROUP[@]}"; do
echo "Installing dependencies from group: $group"
pdm sync --no-editable --no-self --fail-fast --with ${group}
done
fi
- name: Install Your Dependencies (if requested)
shell: bash
run: |
DEPS_FILE="./${{ inputs.working-dir }}/${{ inputs.dependencies-file}}"
if [ -f $DEPS_FILE ]; then
echo "Install extra dependencies from $DEPS_FILE"
pdm add --group extra --no-editable --no-self --fail-fast $(<$DEPS_FILE)
fi
- name: Display Chaos Toolkit info
shell: bash
run: |
echo "Chaos Toolkit environment info"
$(pdm venv activate)
chaos info core
chaos info extensions
- name: Add bin directories to the PATH
shell: bash
run: |
mkdir -p $HOME/bin
echo "Adding $HOME/bin to PATH"
mkdir -p $HOME/${{ inputs.working-dir }}/bin
echo "Adding $HOME/${{ inputs.working-dir }}/bin to PATH"
echo "PATH=$PATH:$HOME/${{ inputs.working-dir }}/bin:$HOME/bin" >> $GITHUB_ENV
- name: Execute the Chaos Toolkit Experiment
working-directory: ${{ inputs.working-dir }}
shell: bash
run: |
echo "Enable the Python environment"
$(pdm venv -p $GITHUB_WORKSPACE activate)
RUN_TEMP_DIR="/tmp/ctk"
mkdir -p $RUN_TEMP_DIR
echo "Run the experiment with the chaos command"
if [ "${{ inputs.verbose }}" == "true" ]; then
chaos --log-file $RUN_TEMP_DIR/chaostoolkit.log --verbose run --journal-path $RUN_TEMP_DIR/journal.json ${{ inputs.experiment-file }}
else
chaos --log-file $RUN_TEMP_DIR/chaostoolkit.log run --journal-path $RUN_TEMP_DIR/journal.json ${{ inputs.experiment-file }}
fi
- name: Upload Chaos Toolkit artifacts
if: ${{ inputs.upload-results-as-artifacts == 'true' }}
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.result-artifact-name }}
path: |
/tmp/ctk/chaostoolkit.log
/tmp/ctk/journal.json