-
Notifications
You must be signed in to change notification settings - Fork 3
155 lines (145 loc) · 4.44 KB
/
ci.yml
File metadata and controls
155 lines (145 loc) · 4.44 KB
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
---
name: CI
on:
- push
permissions:
contents: read
jobs:
files-changed:
name: Detect which file has changed
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
documentation: ${{ steps.changes.outputs.documentation_all }}
python: ${{ steps.changes.outputs.python_all }}
yaml: ${{ steps.changes.outputs.yaml_all }}
steps:
- name: "Check out repository code"
uses: "actions/checkout@v5"
- name: Check for file changes
uses: opsmill/paths-filter@v3.0.2
id: changes
with:
token: ${{ github.token }}
filters: .github/file-filters.yml
python-lint:
if: needs.files-changed.outputs.python == 'true'
needs: ["files-changed"]
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- run: |
pip install uv
uv sync
- run: |
echo "Formatting code"
uv run ruff format
uv run ruff check --select I --fix .
- run: |
echo "Running linters"
uv run ruff check
- run: |
echo "Running type checks"
uv run mypy .
yaml-lint:
if: needs.files-changed.outputs.yaml == 'true'
needs: ["files-changed"]
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- run: |
pip install uv
uv sync
- run: |
echo "Running validation"
uv run yamllint -d "{extends: default, ignore: [.github/, .venv/ , .dev/ ]}" \
-d "{rules: {truthy: {allowed-values: ['true', 'false', 'yes', 'no', 'on', 'off', 'True', 'False']}}}" .
integration-test:
needs: ["python-lint", "yaml-lint"]
runs-on:
group: "huge-runners"
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
timeout-minutes: 60
env:
INFRAHUB_DB_TYPE: neo4j
INFRAHUB_API_TOKEN: '06438eb2-8019-4776-878c-0941b1f1d1ec'
INFRAHUB_TIMEOUT: 600
INFRAHUB_TESTING_LOG_LEVEL: INFO
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
with:
python-version: '3.12'
- run: |
pip install uv
uv sync
- name: "Set environment variables"
run: |
RUNNER_NAME=$(echo "${{ runner.name }}" | grep -o 'ghrunner[0-9]\+' | sed 's/ghrunner\([0-9]\+\)/ghrunner_\1/')
echo "PYTEST_DEBUG_TEMPROOT=/var/lib/github/${RUNNER_NAME}/_temp" >> $GITHUB_ENV
- name: "Run tests"
run: "uv run pytest tests/ -vv"
env:
REPOSITORY_TOKEN: ${{ secrets.GITHUB_TOKEN }}
documentation:
defaults:
run:
working-directory: ./docs
if: |
always() && !cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
needs.files-changed.outputs.documentation == 'true'
needs: ["files-changed", "yaml-lint", "python-lint"]
runs-on: "ubuntu-22.04"
timeout-minutes: 5
steps:
- uses: actions/checkout@v5
with:
submodules: true
- uses: actions/setup-node@v6
with:
node-version: 20
cache: 'npm'
cache-dependency-path: docs/package-lock.json
- name: "Install dependencies"
run: npm install
- run: |
pip install uv
uv sync
- name: "Build docs website"
run: "uv run invoke docs"
validate-documentation-style:
if: |
always() && !cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled')
needs: ["files-changed", "yaml-lint", "python-lint"]
runs-on: "ubuntu-22.04"
timeout-minutes: 5
env:
VALE_VERSION: "3.7.1"
steps:
- uses: "actions/checkout@v5"
with:
submodules: true
# The official GitHub Action for Vale doesn't work, installing manually instead:
# https://github.com/errata-ai/vale-action/issues/103
- name: Download Vale
run: |
curl -sL "https://github.com/errata-ai/vale/releases/download/v${VALE_VERSION}/vale_${VALE_VERSION}_Linux_64-bit.tar.gz" -o vale.tar.gz
tar -xzf vale.tar.gz
- name: "Validate documentation style"
run: ./vale $(find ./docs/docs -type f \( -name "*.mdx" -o -name "*.md" \) )