Skip to content

Commit a96c17c

Browse files
committed
ci: refactor: .default-before-script
1 parent c1f1706 commit a96c17c

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

.gitlab-ci.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ stages:
44
- test
55
- doc
66

7+
.default-before-script: &default-before-script
8+
- python --version
9+
710
wheel:
811
image: python:$PYTHON_VERSION-buster
912
stage: build
1013
before_script:
14+
- *default-before-script
1115
- python -m pip install build
1216
script:
1317
- python -m build --wheel .
@@ -25,6 +29,7 @@ sdist:
2529
image: python:3.10-buster
2630
stage: build
2731
before_script:
32+
- *default-before-script
2833
- python -m pip install build
2934
script:
3035
- python -m build --sdist .
@@ -35,7 +40,7 @@ flake8:
3540
stage: static-analysis
3641
image: pytorch/pytorch:2.2.0-cuda11.8-cudnn8-devel
3742
before_script:
38-
- python --version
43+
- *default-before-script
3944
- python -m pip install flake8 flake8-bugbear flake8-comprehensions
4045
script:
4146
- make check-flake8
@@ -46,7 +51,7 @@ ruff-format:
4651
stage: static-analysis
4752
image: python:3.10-buster
4853
before_script:
49-
- python --version
54+
- *default-before-script
5055
- python -m pip install tomli
5156
- RUFF_VERSION=$(python -c 'import tomli; config = tomli.load(open("uv.lock", "rb")); ruff_config = next(x for x in config["package"] if x["name"] == "ruff"); print(ruff_config["version"])')
5257
- python -m pip install "ruff==$RUFF_VERSION"
@@ -59,7 +64,7 @@ ruff-organize-imports:
5964
stage: static-analysis
6065
image: python:3.10-buster
6166
before_script:
62-
- python --version
67+
- *default-before-script
6368
- python -m pip install tomli
6469
- RUFF_VERSION=$(python -c 'import tomli; config = tomli.load(open("uv.lock", "rb")); ruff_config = next(x for x in config["package"] if x["name"] == "ruff"); print(ruff_config["version"])')
6570
- python -m pip install "ruff==$RUFF_VERSION"
@@ -72,7 +77,7 @@ test:
7277
stage: test
7378
image: pytorch/pytorch:$PYTORCH_IMAGE
7479
before_script:
75-
- python --version
80+
- *default-before-script
7681
- python -m pip install -U pip
7782
- python -m pip install -e .
7883
- python -m pip install pytest pytest-cov plotly
@@ -95,7 +100,7 @@ doc:
95100
stage: doc
96101
image: pytorch/pytorch:2.2.0-cuda11.8-cudnn8-devel
97102
before_script:
98-
- python --version
103+
- *default-before-script
99104
- python -m pip install -e .
100105
- cd docs
101106
- python -m pip install -r requirements.txt

0 commit comments

Comments
 (0)