Skip to content

Commit 534d2bb

Browse files
changed ci config (#346)
Co-authored-by: oleksandr-sandbx <[email protected]>
1 parent b057931 commit 534d2bb

File tree

7 files changed

+206
-114
lines changed

7 files changed

+206
-114
lines changed

.github/workflows/ci.yaml

Lines changed: 15 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -11,119 +11,27 @@ on:
1111

1212
jobs:
1313
test:
14-
name: Run tests
15-
runs-on: ubuntu-latest
16-
steps:
17-
- name: Checkout commit
18-
uses: actions/checkout@v2
19-
- name: Install python
20-
uses: actions/setup-python@v5
21-
with:
22-
python-version: 3.9
23-
- name: Cache packages
24-
uses: actions/cache@v2
25-
with:
26-
path: ~/.cache/pip
27-
key: ${{ runner.os }}-py-3.9-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('setup.cfg') }}
28-
restore-keys: |
29-
${{ runner.os }}-pip-
30-
- name: Install dependencies
31-
run: make setup
32-
- name: Lint
33-
run: |
34-
echo "::add-matcher::.github/actionlint-matcher.json"
35-
make lint
36-
- name: Run unit tests
37-
run: make test_unit
38-
- name: Upload coverage to Codecov
39-
uses: codecov/codecov-action@v3
40-
with:
41-
token: ${{ secrets.CODECOV_TOKEN }}
42-
file: .coverage-unit.xml
43-
flags: unit
44-
name: codecov-unit
45-
- name: Build Docker image
46-
run: make docker_build
47-
env:
48-
IMAGE_TAG: latest
49-
- name: Upload image artifact
50-
uses: neuro-inc/[email protected]
51-
with:
52-
image: platformcontainerruntime
53-
token: ${{ secrets.GITHUB_TOKEN }}
54-
55-
test_integration:
56-
name: Run integration tests
57-
runs-on: ubuntu-latest
58-
if: |
59-
(github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') ||
60-
(github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]')
61-
needs: test
62-
strategy:
63-
fail-fast: false
64-
matrix:
65-
include:
66-
- container_runtime: docker
67-
driver: none
68-
- container_runtime: containerd
69-
driver: docker
70-
env:
71-
MINIKUBE_DRIVER: ${{ matrix.driver }}
72-
MINIKUBE_K8S_VERSION: 1.23.6
73-
MINIKUBE_CONTAINER_RUNTIME: ${{ matrix.container_runtime }}
74-
steps:
75-
- name: Checkout commit
76-
uses: actions/checkout@v2
77-
- name: Install python
78-
uses: actions/setup-python@v2
79-
with:
80-
python-version: 3.9
81-
- name: Cache packages
82-
uses: actions/cache@v2
83-
with:
84-
path: ~/.cache/pip
85-
key: ${{ runner.os }}-py-3.9-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('setup.cfg') }}
86-
- name: Install dependencies
87-
run: make setup
88-
- name: Start minikube
89-
run: |
90-
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
91-
sudo apt-get update
92-
sudo apt-get install -y conntrack
93-
sudo install minikube-linux-amd64 /usr/local/bin/minikube
94-
minikube start \
95-
--wait=all \
96-
--wait-timeout=10m0s \
97-
--force="true" \
98-
--driver="$MINIKUBE_DRIVER" \
99-
--kubernetes-version="$MINIKUBE_K8S_VERSION" \
100-
--container-runtime="$MINIKUBE_CONTAINER_RUNTIME"
101-
sudo chown -R $USER $HOME/.kube /root/.minikube
102-
sudo chmod -R a+r $HOME/.kube /root/.minikube
103-
sudo find /root/.minikube -name id_rsa -exec chmod 600 {} \;
104-
- name: Run integration tests
105-
run: make test_integration
106-
- name: Upload coverage to Codecov
107-
uses: codecov/codecov-action@v3
108-
with:
109-
token: ${{ secrets.CODECOV_TOKEN }}
110-
file: .coverage-integration.xml
111-
flags: integration
112-
name: codecov-integration
14+
name: All checks are passed
15+
uses: ./.github/workflows/test.yaml
11316

11417
release:
11518
name: Create release
116-
needs: test_integration
117-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
118-
uses: neuro-inc/reuse/.github/workflows/release-service.yaml@v24.9.0
19+
needs: test
20+
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/'))
21+
uses: neuro-inc/reuse/.github/workflows/release-service.yaml@v25.4.0
11922
with:
12023
image: platformcontainerruntime
12124
helm_charts: platform-container-runtime
12225

123-
deploy_dev:
124-
name: Deploy on dev
26+
deploy:
27+
name: Deploy
12528
needs: release
126-
uses: neuro-inc/reuse/.github/workflows/[email protected]
29+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
30+
uses: neuro-inc/reuse/.github/workflows/[email protected]
31+
secrets:
32+
tf_api_token: ${{ secrets.TF_API_TOKEN }}
12733
with:
128-
helm_charts: platform-container-runtime
129-
version: ${{ needs.release.outputs.version }}
34+
environment: dev
35+
dev_workspace: ${{ vars.DEV_TFC_WORKSPACE_JSON }}
36+
variables: |
37+
platform_container_runtime=${{ needs.release.outputs.version }}

.github/workflows/test.yaml

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
on:
2+
workflow_call: {}
3+
4+
jobs:
5+
6+
lint:
7+
name: Lint
8+
runs-on: ubuntu-latest
9+
timeout-minutes: 10
10+
steps:
11+
- name: Checkout commit
12+
uses: actions/checkout@v4
13+
with:
14+
ref: ${{ github.event.pull_request.head.sha }}
15+
fetch-depth: 0
16+
- name: Install Python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version-file: .python-version
20+
- name: Cache packages
21+
uses: actions/cache@v4
22+
with:
23+
path: ~/.cache/pip
24+
key: ${{ runner.os }}-py-3.9-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('setup.cfg') }}
25+
restore-keys: |
26+
${{ runner.os }}-pip-
27+
- name: Install dependencies
28+
run: make setup
29+
- name: Lint
30+
run: |
31+
echo "::add-matcher::.github/actionlint-matcher.json"
32+
make lint
33+
34+
unit:
35+
name: Unit tests
36+
runs-on: ubuntu-latest
37+
steps:
38+
- name: Checkout commit
39+
uses: actions/checkout@v4
40+
with:
41+
ref: ${{ github.event.pull_request.head.sha }}
42+
fetch-depth: 0
43+
- name: Install Python
44+
uses: actions/setup-python@v5
45+
with:
46+
python-version-file: .python-version
47+
- name: Cache packages
48+
uses: actions/cache@v4
49+
with:
50+
path: ~/.cache/pip
51+
key: ${{ runner.os }}-py-3.9-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('setup.cfg') }}
52+
restore-keys: |
53+
${{ runner.os }}-pip-
54+
- name: Install dependencies
55+
run: make setup
56+
- name: Run unit tests
57+
run: make test_unit
58+
- name: Upload coverage to Codecov
59+
uses: codecov/codecov-action@v3
60+
with:
61+
token: ${{ secrets.CODECOV_TOKEN }}
62+
file: .coverage-unit.xml
63+
flags: unit
64+
name: codecov-unit
65+
66+
integration:
67+
name: Integration tests
68+
runs-on: ubuntu-latest
69+
strategy:
70+
fail-fast: false
71+
matrix:
72+
include:
73+
- container_runtime: docker
74+
driver: none
75+
- container_runtime: containerd
76+
driver: docker
77+
env:
78+
# keep Minikube state out of /home/runner
79+
MINIKUBE_HOME: ${{ github.workspace }}/.minikube
80+
MINIKUBE_DRIVER: ${{ matrix.driver }}
81+
MINIKUBE_K8S_VERSION: 1.23.6
82+
MINIKUBE_CONTAINER_RUNTIME: ${{ matrix.container_runtime }}
83+
steps:
84+
- name: Checkout commit
85+
uses: actions/checkout@v4
86+
with:
87+
ref: ${{ github.event.pull_request.head.sha }}
88+
fetch-depth: 0
89+
90+
- name: Install Python
91+
uses: actions/setup-python@v5
92+
with:
93+
python-version-file: .python-version
94+
95+
- name: Cache packages
96+
uses: actions/cache@v4
97+
with:
98+
path: ~/.cache/pip
99+
key: ${{ runner.os }}-py-3.9-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('setup.cfg') }}
100+
restore-keys: |
101+
${{ runner.os }}-pip-
102+
103+
- name: Install dependencies
104+
run: make setup
105+
106+
- name: Fix minikube home permissions
107+
run: |
108+
mkdir -p "$MINIKUBE_HOME"
109+
sudo chown -R "$USER:$USER" "$MINIKUBE_HOME"
110+
chmod -R u+rwX "$MINIKUBE_HOME"
111+
112+
- name: Start minikube
113+
run: |
114+
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
115+
sudo apt-get update
116+
sudo apt-get install -y conntrack
117+
sudo install minikube-linux-amd64 /usr/local/bin/minikube
118+
minikube start \
119+
--wait=all \
120+
--wait-timeout=10m0s \
121+
--force="true" \
122+
--driver="$MINIKUBE_DRIVER" \
123+
--kubernetes-version="$MINIKUBE_K8S_VERSION" \
124+
--container-runtime="$MINIKUBE_CONTAINER_RUNTIME"
125+
sudo chown -R $USER $HOME/.kube /root/.minikube
126+
sudo chmod -R a+r $HOME/.kube /root/.minikube
127+
sudo find /root/.minikube -name id_rsa -exec chmod 600 {} \;
128+
- name: Run integration tests
129+
run: make test_integration
130+
131+
- name: Upload coverage to Codecov
132+
uses: codecov/codecov-action@v3
133+
with:
134+
token: ${{ secrets.CODECOV_TOKEN }}
135+
file: .coverage-integration.xml
136+
flags: integration
137+
name: codecov-integration
138+
139+
image-upload:
140+
name: Upload image artifact
141+
runs-on: ubuntu-latest
142+
steps:
143+
- name: Checkout commit
144+
uses: actions/checkout@v4
145+
with:
146+
ref: ${{ github.event.pull_request.head.sha }}
147+
fetch-depth: 0
148+
- name: Install Python
149+
uses: actions/setup-python@v5
150+
with:
151+
python-version-file: .python-version
152+
- name: Cache packages
153+
uses: actions/cache@v4
154+
with:
155+
path: ~/.cache/pip
156+
key: ${{ runner.os }}-py-3.9-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('setup.cfg') }}
157+
restore-keys: |
158+
${{ runner.os }}-pip-
159+
- name: Install dependencies
160+
run: make setup
161+
- name: Build Docker image
162+
run: make docker_build
163+
env:
164+
IMAGE_TAG: latest
165+
- name: Upload image artifact
166+
uses: neuro-inc/[email protected]
167+
with:
168+
image: platformcontainerruntime
169+
token: ${{ secrets.GITHUB_TOKEN }}
170+
171+
check:
172+
name: Check
173+
needs:
174+
- lint
175+
- unit
176+
- integration
177+
- image-upload
178+
runs-on: ubuntu-latest
179+
if: always()
180+
steps:
181+
- name: Decide whether the needed jobs succeeded or failed
182+
uses: re-actors/alls-green@release/v1
183+
with:
184+
jobs: ${{ toJSON(needs) }}

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,6 @@ target/
8282
profile_default/
8383
ipython_config.py
8484

85-
# pyenv
86-
.python-version
87-
8885
# pipenv
8986
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
9087
# However, in case of collaboration, if having platform-specific dependencies or dependencies

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.9.18

Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
FROM python:3.9.9-slim-bullseye AS installer
1+
ARG PY_VERSION=3.9.18
2+
3+
FROM python:${PY_VERSION}-slim-bullseye AS installer
24

35
ENV PATH=/root/.local/bin:$PATH
46

@@ -9,7 +11,7 @@ COPY dist /tmp/dist
911
RUN ls /tmp/dist
1012
RUN pip install --user --find-links /tmp/dist platform-container-runtime
1113

12-
FROM python:3.9.9-slim-bullseye as service
14+
FROM python:${PY_VERSION}-slim-bullseye as service
1315

1416
LABEL org.opencontainers.image.source = "https://github.com/neuro-inc/platform-container-runtime"
1517

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ dev =
3838
mypy==1.6.1
3939
mypy-protobuf==3.5.0
4040
pre-commit==4.2.0
41-
pytest==8.3.5
41+
pytest==7.4.0
4242
pytest-asyncio==0.21.1
4343
pytest-cov==4.1.0
4444
types-protobuf

tests/integration/test_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ async def test_commit(
410410
registry_address: str,
411411
kube_container_runtime: str,
412412
) -> None:
413-
if kube_container_runtime == "cri-o":
413+
if kube_container_runtime in ("cri-o", "containerd"):
414414
pytest.skip("Commit is not supported")
415415

416416
async with run("ubuntu:20.10", 'bash -c "sleep infinity"') as pod:

0 commit comments

Comments
 (0)