-
Notifications
You must be signed in to change notification settings - Fork 2
200 lines (192 loc) · 6.32 KB
/
build.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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
---
name: Lint and test
on:
pull_request:
env:
PYTHON_VERSION: '3.10'
jobs:
lint:
name: Run linters
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: snok/install-poetry@v1
with:
version: 1.6.1
virtualenvs-create: false
- name: Install dependencies and run lints
run: |
# Necessary for running the mypy pre-commit hook
poetry config virtualenvs.create false
poetry install
- name: Linting and static code checks
continue-on-error: true
id: pre-commit-first-run
uses: pre-commit/action@v3.0.1
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
id: auto-commit-action
with:
create_branch: false
commit_message: Linting and static code checks
# If the first run failed, run the checks again to ensure that the changes fixed the issue.
- name: Linting and static code checks try 2
if: steps.pre-commit-first-run.outcome != 'success'
uses: pre-commit/action@v3.0.1
test-no-alpha:
name: Run tests without alpha features
runs-on: ubuntu-latest
environment: dev
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- uses: snok/install-poetry@v1
with:
version: 1.6.1
virtualenvs-create: false
- name: Install core dependencies
run: poetry install
- name: Turn off alpha features
run: python dev.py alpha --off
- name: Run pytest
env:
IS_GITHUB_ACTIONS: "true"
run: pytest tests/test_unit -n8
test:
name: Run tests
runs-on: ubuntu-latest
environment: dev
env:
CDF_CLUSTER: ${{ secrets.CDF_CLUSTER }}
CDF_PROJECT: ${{ secrets.CDF_PROJECT }}
IDP_CLIENT_ID: ${{ secrets.IDP_CLIENT_ID }}
IDP_CLIENT_SECRET: ${{ secrets.IDP_CLIENT_SECRET }}
IDP_TOKEN_URL: ${{ secrets.IDP_TOKEN_URL }}
strategy:
fail-fast: false
matrix:
python-version:
- "3.10"
# Skipping 3.11 as we assume it is covered by 3.10 and 3.12
- "3.12"
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: snok/install-poetry@v1
with:
version: 1.6.1
virtualenvs-create: false
- name: Install core dependencies
run: |
poetry install
- name: Run pytest
env:
IS_GITHUB_ACTIONS: "true"
run: pytest tests/test_unit -n8
coverage:
name: Create coverage report
runs-on: ubuntu-latest
environment: dev
env:
CDF_CLUSTER: ${{ secrets.CDF_CLUSTER }}
CDF_PROJECT: ${{ secrets.CDF_PROJECT }}
IDP_CLIENT_ID: ${{ secrets.IDP_CLIENT_ID }}
IDP_CLIENT_SECRET: ${{ secrets.IDP_CLIENT_SECRET }}
IDP_TOKEN_URL: ${{ secrets.IDP_TOKEN_URL }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: actions/setup-python@v5
with:
python-version: 3.11
- uses: snok/install-poetry@v1
with:
version: 1.6.1
virtualenvs-create: false
- name: Install core dependencies
run: |
poetry install
- name: Create test coverage report
env:
IS_GITHUB_ACTIONS: "true"
run: pytest --cov=cognite_toolkit/ --cov-config=pyproject.toml --cov-report=xml:coverage.xml tests/ -n8
- name: Push coverage report to PR
uses: orgoro/coverage@v3.2
with:
coverageFile: coverage.xml
thresholdAll: 0.6
token: ${{ secrets.GITHUB_TOKEN }}
dry-run-demo:
runs-on: ubuntu-latest
environment: dev
env:
CDF_CLUSTER: ${{ secrets.CDF_CLUSTER }}
CDF_PROJECT: ${{ secrets.CDF_PROJECT }}
IDP_CLIENT_ID: ${{ secrets.IDP_CLIENT_ID }}
IDP_CLIENT_SECRET: ${{ secrets.IDP_CLIENT_SECRET }}
IDP_TOKEN_URL: ${{ secrets.IDP_TOKEN_URL }}
LOGIN_FLOW: client_credentials
name: Dry Run Demo
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: snok/install-poetry@v1
with:
version: 1.6.1
virtualenvs-create: false
- name: Install dependencies and build the package
run: |
poetry install
poetry build
- name: Install cdf-tk
run: pip install .
- name: "Not collect metrics"
run: cdf collect opt-out
- name: Initialize project
run: cdf modules init demo_project --clean --all
- name: "Pre-processing for demo environment"
run: python ./demo/preproc.py --modules all
- name: "Build the templates"
run: cdf build --build-dir=./build --env=demo -o ./demo_project
- name: "Verify and create access rights"
run: cdf auth verify --no-prompt
- name: "Test clean --dry-run"
run: |
cdf clean --env=demo ./build --dry-run
- name: "Deploy the templates --dry-run"
run: |
cdf deploy --drop --env=demo ./build --dry-run
Build-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: version
name: Toolkit Version
# Read the version from the cognite_toolkit/_version.py file
run: echo "version=$(sed -n 's/^__version__ = "\(.*\)"/\1/p' cognite_toolkit/_version.py)" >> $GITHUB_ENV
- name: Build Image
run: |
docker build -t cognite/toolkit:${{ env.version }} -t cognite/toolkit:latest .
- name: Test Image
run: |
docker run -v $(pwd):/app cognite/toolkit:latest cdf modules init my_org --all
- name: Verfiy Created Files
run: |
if [ -d "my_org" ]; then
echo "My org successfully created"
else
echo "My org failed creation"
exit 1
fi
- name: Inspection
run: |
ls -l my_org
ls -l my_org/modules