Skip to content

Commit

Permalink
refactor: simplify GitLab CI/CD script
Browse files Browse the repository at this point in the history
  • Loading branch information
lsorber authored Dec 19, 2023
1 parent 8a23f88 commit c512d12
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
node-version: 21

- name: Install @devcontainers/cli
run: npm install --location=global @devcontainers/cli@0.54.0
run: npm install --location=global @devcontainers/cli@0.55.0

- name: Start Dev Container with Python ${{ matrix.python-version }}
run: |
Expand Down
7 changes: 5 additions & 2 deletions {{ cookiecutter.__package_name_kebab_case }}/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
.git
.*_cache
# Caches
.*_cache/

# Git
.git/
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
node-version: 21

- name: Install @devcontainers/cli
run: npm install --location=global @devcontainers/cli@0.54.0
run: npm install --location=global @devcontainers/cli@0.55.0

- name: Start Dev Container
run: |
Expand Down
19 changes: 10 additions & 9 deletions {{ cookiecutter.__package_name_kebab_case }}/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,25 @@ stages:
variables:
DOCKER_TLS_CERTDIR: "/certs"

.parallel:
.python_matrix:
parallel:
matrix:
- PYTHON_VERSION: ["{{ cookiecutter.python_version }}"]

.install_devcontainers_cli: &install_devcontainers_cli
.install_devcontainers_cli:
cache:
paths:
- .apk_cache
- .npm_cache
before_script:
# Install the Dev Container CLI.
- mkdir -p .apk_cache && apk add --update-cache --cache-dir .apk_cache nodejs npm
- npm install --global --cache .npm_cache --prefer-offline @devcontainers/[email protected]
- mkdir -p .apk_cache && apk add --cache-dir .apk_cache npm
- npm install --cache .npm_cache --global --prefer-offline @devcontainers/[email protected]

# Build the Dev Container.
Build:
extends: .parallel
extends:
- .python_matrix
- .install_devcontainers_cli
stage: build
image: docker:latest
services:
Expand Down Expand Up @@ -55,11 +56,12 @@ Build:
artifacts:
reports:
dotenv: .env
<<: *install_devcontainers_cli

# Lint and test the package.
Test:
extends: .parallel
extends:
- .python_matrix
- .install_devcontainers_cli
stage: test
image: docker:latest
services:
Expand All @@ -81,7 +83,6 @@ Test:
- reports/pytest.xml
untracked: true
when: always
<<: *install_devcontainers_cli

{% if not cookiecutter.with_fastapi_api|int and not cookiecutter.with_streamlit_app|int -%}
# Publish this package version to {% if cookiecutter.private_package_repository_name %}a private package repository{% else %}PyPI{% endif %}.
Expand Down

0 comments on commit c512d12

Please sign in to comment.