forked from cloud-custodian/cloud-custodian
-
Notifications
You must be signed in to change notification settings - Fork 0
170 lines (156 loc) · 4.63 KB
/
ci.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: "CI"
on:
push:
branches:
- main
pull_request:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
Lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install Linter
run: |
python -m pip install --upgrade pip
pip install ruff black
- name: Set up Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_wrapper: false
- name: Lint Check
run: |
make lint
- name: Check Workflows
run: |
bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
./actionlint -color
Analyzer:
runs-on: ubuntu-latest
needs: Lint
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Run Bandit
run: |
python -m pip install bandit
make analyzer-bandit
- name: Run Semgrep
run: |
python -m pip install semgrep
make analyzer-semgrep
Docs:
runs-on: ubuntu-latest
needs: Lint
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v3
- name: Install Custodian
uses: ./.github/composites/install
with:
python-version: "3.11"
- name: Set up doc cache
uses: actions/cache@v3
id: sphinx
with:
path: |
docs/build
docs/source/aws/resources
docs/source/gcp/resources
docs/source/azure/resources
docs/source/awscc/resources
docs/source/tencentcloud/resources
key: sphinx-docs-${{ runner.os }}-3.11-v2-${{ hashFiles('**/poetry.lock') }}
- name: Build Docs
shell: bash
run: |
make sphinx
- name: Update Docs Cache
# basically to prevent the docs cache from going stale as we're not keying
# on its contents, on merges to main we update the cache to prevent
# staleness.
if: ${{ github.event_name == 'push' }}
uses: actions/cache/save@v3
with:
path: |
docs/build
docs/source/aws/resources
docs/source/gcp/resources
docs/source/azure/resources
docs/source/awscc/resources
docs/source/tencentcloud/resources
key: sphinx-docs-${{ runner.os }}-3.11-v2-${{ hashFiles('**/poetry.lock') }}
- name: Deploy Docs
if: ${{ github.event_name == 'push' }}
uses: ./.github/composites/docs-publish
with:
aws-role: ${{ secrets.DOCS_PUBLISH_ROLE }}
docs-dir: docs/build/html
bucket-url: s3://cloudcustodian.io/docs
Docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: c7n build and test
uses: ./.github/composites/docker-build-push
with:
name: c7n
push: false
platforms: linux/amd64
Tests:
runs-on: "${{ matrix.os }}"
needs: Lint
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.11"]
include:
- os: ubuntu-latest
python-version: "3.10"
- os: ubuntu-latest
python-version: "3.9"
- os: ubuntu-latest
python-version: "3.8"
steps:
- uses: actions/checkout@v3
- name: Set up Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_wrapper: false
- name: Install Custodian
uses: ./.github/composites/install
with:
python-version: ${{ matrix.python-version }}
- name: Test
shell: bash
env:
COV_RUN: ${{ contains(matrix.python-version, '3.10') && contains(matrix.os, 'ubuntu') }}
run: |
if [[ "$COV_RUN" == "true" ]]
then
make test-coverage COVERAGE_TYPE=term
poetry run coverage xml
else
make test
fi
- name: Upload Code Coverage
uses: codecov/codecov-action@v3
if: contains(matrix.python-version, '3.10') && contains(matrix.os, 'ubuntu')
with:
files: ./coverage.xml
name: codecov
- name: License Check
if: contains(matrix.python-version, '3.10') && contains(matrix.os, 'ubuntu')
run: |
poetry run python tools/dev/license-check.py