-
Notifications
You must be signed in to change notification settings - Fork 27
154 lines (133 loc) · 4.09 KB
/
cicd.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
name: CI/CD
on:
push:
branches:
- dev
- feature/*
- chore/*
- hotfix/*
pull_request:
branches:
- master
- dev
jobs:
run_pytest:
runs-on: ubuntu-latest
if: ${{ !contains(github.event.head_commit.message, 'docs') && !contains(github.event.head_commit.message, 'documentation') }}
timeout-minutes: 15
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up mamba environment
uses: mamba-org/setup-micromamba@v1
with:
micromamba-version: '1.3.1-0'
environment-file: environment.yml
environment-name: BiG-SCAPE
init-shell: bash
generate-run-shell: true
- name: Install dependencies
shell: micromamba-shell {0}
run: |
python -m pip install pytest
- name: Test with Pytest
shell: micromamba-shell {0}
run: |
pytest
generate_coverage:
runs-on: ubuntu-latest
if: ${{ !contains(github.event.head_commit.message, 'docs') && !contains(github.event.head_commit.message, 'documentation') }}
timeout-minutes: 15
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up mamba environment
uses: mamba-org/setup-micromamba@v1
with:
micromamba-version: '1.3.1-0'
environment-file: environment.yml
environment-name: BiG-SCAPE
init-shell: bash
generate-run-shell: true
- name: Install dependencies
shell: micromamba-shell {0}
run: |
python -m pip install pytest coverage coverage-badge
- name: Test with Pytest
shell: micromamba-shell {0}
run: |
coverage run -m pytest
coverage report
mkdir badges
coverage-badge -o badges/coverage.svg
- name: Upload badges folder
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: badges
destination_dir: badges
keep_files: true
run_linters:
runs-on: ubuntu-latest
if: ${{ !contains(github.event.head_commit.message, 'docs') && !contains(github.event.head_commit.message, 'documentation') }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up python
uses: actions/setup-python@main
with:
python-version: "3.9"
- name: Install dependencies
shell: bash
run: python -m pip install pylint flake8 anybadge
- name: Run flake8
shell: bash
run: flake8 big_scape
- name: Run pylint & generate badge
shell: bash
run: |
score=$(pylint big_scape --exit-zero | grep 'rated at' | sed -r 's/^.*at ([0-9]+\.[0-9]+).*$/\1/')
echo $score
mkdir badges
rm -f badges/pylint.svg
anybadge -l pylint -v $score -f badges/pylint.svg 2=red 4=orange 8=yellow 10=green
- name: Save badge to cache
uses: actions/cache/save@v3
with:
path: badges
key: cache-${{ github.run_id }}-${{ github.run_attempt }}
- name: Upload badges folder
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: badges
destination_dir: badges
keep_files: true
# upload_badges:
# runs-on: ubuntu-latest
# if: ${{ !contains(github.event.head_commit.message, 'docs') && !contains(github.event.head_commit.message, 'documentation') }}
# needs:
# - run_pytest
# - run_pylint
# steps:
# - name: Setup cache
# uses: actions/cache/restore@v3
# with:
# path: badges
# key: cache-${{ github.run_id }}-${{ github.run_attempt }}
# - name: Check cache hit
# if: steps.cache.outputs.cache-hit != 'true'
# run: |
# Could not find cache
# exit 1
# - name: LS badges dir
# shell: bash
# run: |
# ls -l
# ls -l badges
# - name: Upload badges folder
# uses: peaceiris/actions-gh-pages@v3
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# publish_dir: badges
# destination_dir: badges