-
Notifications
You must be signed in to change notification settings - Fork 34
132 lines (113 loc) · 5.15 KB
/
pre-merge-checks-plugin-st.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
# Pre-merge Checks (for Python projects)
# 1. Unit tests with code coverage (pytest)
# 2. Code quality analysis (flake8)
# 3. Dependency analysis (vulnerabilities)
# 4. Dependency analysis (undesirable licenses)
# 5. Deploy reports generated from the above to GitHub Pages
name: Pre-Merge Checks (plugin-st)
on:
# Runs when a pull request to main is being assigned
pull_request:
types: [ assigned, synchronize ]
branches:
- 'main'
paths:
- 'stock-plugins/aiverify.stock.shap-toolbox/**'
# Run this workflow manually from Actions tab
workflow_dispatch:
# Allow one concurrent deployment
concurrency:
group: ${{ github.repository }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
pre-merge-checks:
# Run only when PR is assigned, even on subsequent commits (i.e. synchronize)
if: (github.event_name == 'pull_request' && github.event.pull_request.assignee != null) || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
timeout-minutes: 40
steps:
# Checkout code
- name: Checkout code
uses: actions/checkout@v3
with:
sparse-checkout: |
test-engine-core-modules
stock-plugins/aiverify.stock.shap-toolbox
# Install dependencies
- name: Setup pip cache/install
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
cache-dependency-path: stock-plugins/aiverify.stock.shap-toolbox
- name: Install dependencies for core-modules
working-directory: ${{ github.workspace }}/test-engine-core-modules
run: |
pip install -r requirements.txt
- name: Install dependencies for plugin
working-directory: ${{ github.workspace }}/stock-plugins/aiverify.stock.shap-toolbox
run: |
cd algorithms/*/
curl -H 'Authorization: token ${{ secrets.CHECKOUT_TOKEN }}' -H 'Accept: application/vnd.github.v3.raw' -O -L https://api.github.com/repos/IMDA-BTG/aiverify/contents/test-engine-core/dist/test_engine_core-0.9.0.tar.gz
pip install -r requirements.txt
pip install test_engine_core-0.9.0.tar.gz
pip install pytest pytest-mock pytest-html pytest-json pytest-cov coverage
pip install flake8 flake8-html anybadge
# Unit Tests & Coverage
- name: Unit tests with coverage
working-directory: ${{ github.workspace }}/stock-plugins/aiverify.stock.shap-toolbox
if: ${{ ! cancelled() }}
timeout-minutes: 30
run: |
cd algorithms/*/
bash ci/run-test.sh -m
# flake8
- name: Code quality analysis - lint
working-directory: ${{ github.workspace }}/stock-plugins/aiverify.stock.shap-toolbox
if: ${{ ! cancelled() }}
run: |
cd algorithms/*/
bash ci/run-flake8.sh
- name: Uninstall dependencies (core-modules & dev)
working-directory: ${{ github.workspace }}/test-engine-core-modules
if: ${{ ! cancelled() }}
run: |
pip uninstall -y -r requirements.txt
pip uninstall -y pytest pytest-mock pytest-html pytest-json pytest-cov coverage
# pip-audit
- name: Dependency analysis - vulnerabilities & licenses
working-directory: ${{ github.workspace }}/stock-plugins/aiverify.stock.shap-toolbox
if: ${{ ! cancelled() }}
run: |
cd algorithms/*/
bash ci/run-pip-audit.sh
### Publish reports to ci dashboard ###
- name: Checkout dashboard
if: ${{ github.event.pull_request.head.repo.full_name == github.repository && always() }}
uses: actions/checkout@v3
with:
repository: IMDA-BTG/ci-dashboard
token: ${{ secrets.CHECKOUT_TOKEN }}
ref: main
path: check-results
- name: Push results to dashboard
if: ${{ github.event.pull_request.head.repo.full_name == github.repository && always() }}
working-directory: ${{ github.workspace }}/check-results
run: |
set +e
find ../ -type f -name ".gitignore" -exec rm {} +
[ -d "docs/pre-merge/plugin-st" ] && rm -rf docs/pre-merge/plugin-st
mkdir -p docs/pre-merge/plugin-st
mv ../stock-plugins/aiverify.stock.shap-toolbox/algorithms/*/htmlcov docs/pre-merge/plugin-st/
mv ../stock-plugins/aiverify.stock.shap-toolbox/algorithms/*/flake8-report docs/pre-merge/plugin-st/
mv ../stock-plugins/aiverify.stock.shap-toolbox/algorithms/*/assets docs/pre-merge/plugin-st/
mv ../stock-plugins/aiverify.stock.shap-toolbox/algorithms/*/*.svg docs/pre-merge/plugin-st/
mv ../stock-plugins/aiverify.stock.shap-toolbox/algorithms/*/*.html docs/pre-merge/plugin-st/
mv ../stock-plugins/aiverify.stock.shap-toolbox/algorithms/*/*.md docs/pre-merge/plugin-st/
mv ../stock-plugins/aiverify.stock.shap-toolbox/algorithms/*/*.txt docs/pre-merge/plugin-st/
git add docs/pre-merge/plugin-st
git config user.name "imda-btg"
git config user.email "[email protected]"
git commit -m "feat(portal) actions publish plugin-st reports to dashboard"
git push
set -e