-
Notifications
You must be signed in to change notification settings - Fork 1
131 lines (116 loc) · 4.21 KB
/
checks.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
name: Code Test & Analysis
#on: [push, pull_request]
on:
push:
branches:
- develop
- main
paths-ignore:
- "LICENSE"
- ".gitignore"
- "**.md"
jobs:
analysis:
runs-on: ubuntu-latest
outputs:
run_job: ${{ steps.check_files.outputs.run_job }}
strategy:
matrix:
python-version: [3.8]
steps:
- name: Error handling # https://github.com/actions/checkout/issues/317
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- uses: pre-commit/action@v2.0.0
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox tox-gh-actions
- name: Run Tox
run: |
python -m tox -e docs
python -m tox -e tests
- name: Generate coverage report
if: ${{ steps.vars.outputs.branch_name }} == 'main'
run: |
pip install pytest
pip install hcl
pip install argparse
pip install pytest-cov
pip install ruamel.yaml
python -m pytest --cov=./ --cov-report=xml
- name: Upload coverage to Codecov
if: ${{ steps.vars.outputs.branch_name }} == 'main'
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./
flags: unittests
env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: true
path_to_write_report: ./coverage/codecov_report.txt
verbose: true
- name: Check modified file(s)
id: check_files
run: |
echo "=============== list modified files ==============="
git diff --name-only HEAD^ HEAD
echo "========== check paths of modified files =========="
git diff --name-only HEAD^ HEAD > '${{ runner.temp }}/files.txt'
while IFS= read -r file
do
echo $file
if [[ $file ]]; then
echo "Some files changed."
echo "::set-output name=run_job::true"
break
else
echo "::set-output name=run_job::false"
fi
done < '${{ runner.temp }}/files.txt'
- name: check modified file
id: check_file_github_actions
run: |
echo "=============== list modified files ==============="
git diff --name-only HEAD^ HEAD
echo "========== check paths of modified files =========="
git diff --name-only HEAD^ HEAD > '${{ runner.temp }}/github_actions_files.txt'
while IFS= read -r file
do
echo $file
if [[ $file != '.github/workflows/*.yml' ]]; then
echo "Some files changed."
echo "::set-output name=run_job::true"
break
else
echo "::set-output name=run_job::false"
fi
done < '${{ runner.temp }}/github_actions_files.txt'
- name: Get current branch name
if: hashFiles('${{ runner.temp }}/files.txt') != ''
id: vars
run: |
echo ::set-output name=branch_name::${GITHUB_REF##*/}
- name: Commit files
if: ${{ steps.vars.outputs.branch_name == 'develop' && hashFiles('${{ runner.temp }}/github_actions_files.txt') == '' }}
run: |
git config --local user.email "terraform+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add -A; git commit -m "Add changes"; git push
# Create a pull request from develop to main branch0
- name: Pull requests
if: ${{ steps.vars.outputs.branch_name == 'develop' && hashFiles('${{ runner.temp }}/github_actions_files.txt') == '' }}
uses: vsoch/pull-request-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PULL_REQUEST_BRANCH: "main"
PULL_REQUEST_FROM_BRANCH: ${{ github.ref }}