From 549185be29d07e1b5ac09bb4c5083d36984cce38 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 7 May 2024 02:26:24 +0000 Subject: [PATCH 01/26] ci: test container before push --- .devcontainer/Dockerfile | 3 +++ .gitlab/workflows/devcontainer.yml | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index aa60b014..fb1c63f3 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -50,6 +50,9 @@ RUN groupadd --gid $USER_GID $USERNAME \ # Set permission for related folders RUN chown -R $USER_UID:$USER_GID $PIPX_HOME $PIPX_BIN_DIR +# Set default working directory +WORKDIR /workspace + ######################################################################################## # Build image is an intermediate image used for building the project. ######################################################################################## diff --git a/.gitlab/workflows/devcontainer.yml b/.gitlab/workflows/devcontainer.yml index 3d0cccaf..051840ba 100644 --- a/.gitlab/workflows/devcontainer.yml +++ b/.gitlab/workflows/devcontainer.yml @@ -27,9 +27,15 @@ dev-container-publish: --cache-to type=registry,ref=${CI_REGISTRY_IMAGE}/dev-cache:py${PYTHON_VERSION},mode=max \ --file .devcontainer/Dockerfile \ --provenance false \ - --push \ + --load \ --tag ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \ --target dev + - | + docker run --rm \ + -v ${PWD}:/workspace \ + -e PDM_BUILD_SCM_VERSION=0.0.0 \ + ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \ + make dev lint test doc build services: - docker:26.1.1@sha256:56e2c522194d81689c2787c76304777199cbdc741d7dd798d06e33967361d92f stage: build From b915bf413894fc9106cda748ea893aaba902cfb7 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 7 May 2024 02:43:54 +0000 Subject: [PATCH 02/26] minor --- .devcontainer/Dockerfile | 2 +- .gitlab/workflows/devcontainer.yml | 3 ++- pyproject.toml | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index fb1c63f3..adf569e1 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -65,7 +65,7 @@ COPY src/ /workspace/src # Install dependencies and project into the local packages directory. WORKDIR /workspace -ARG PDM_BUILD_SCM_VERSION=0.0.0 +ARG PDM_BUILD_SCM_VERSION RUN mkdir __pypackages__ && PDM_BUILD_SCM_VERSION=${PDM_BUILD_SCM_VERSION} pdm sync --prod --no-editable ######################################################################################## diff --git a/.gitlab/workflows/devcontainer.yml b/.gitlab/workflows/devcontainer.yml index 051840ba..f473bd7b 100644 --- a/.gitlab/workflows/devcontainer.yml +++ b/.gitlab/workflows/devcontainer.yml @@ -16,6 +16,7 @@ dev-container-publish: if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push" - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "web" script: + - env | sort - docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY} - docker context create builder - docker buildx create builder --name container --driver docker-container --use @@ -32,8 +33,8 @@ dev-container-publish: --target dev - | docker run --rm \ + -e CI_PAGES_URL \ -v ${PWD}:/workspace \ - -e PDM_BUILD_SCM_VERSION=0.0.0 \ ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \ make dev lint test doc build services: diff --git a/pyproject.toml b/pyproject.toml index 75a90762..6d5aebc9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -98,6 +98,7 @@ test = [ ] [tool.pdm.version] +fallback_version = "0.0.0" source = "scm" [tool.pytest.ini_options] From 1ce172adff4509c0698f5ad6499a13be0dc94293 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 7 May 2024 02:51:03 +0000 Subject: [PATCH 03/26] push --- .gitlab/workflows/devcontainer.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.gitlab/workflows/devcontainer.yml b/.gitlab/workflows/devcontainer.yml index f473bd7b..07ac5435 100644 --- a/.gitlab/workflows/devcontainer.yml +++ b/.gitlab/workflows/devcontainer.yml @@ -37,6 +37,14 @@ dev-container-publish: -v ${PWD}:/workspace \ ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \ make dev lint test doc build + - | + docker buildx build . \ + --build-arg PYTHON_VERSION=${PYTHON_VERSION} \ + --file .devcontainer/Dockerfile \ + --provenance false \ + --push \ + --tag ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \ + --target dev services: - docker:26.1.1@sha256:56e2c522194d81689c2787c76304777199cbdc741d7dd798d06e33967361d92f stage: build From 6de99c7e1c08d1592ffcc5b081df6ef929d146b5 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 7 May 2024 03:08:53 +0000 Subject: [PATCH 04/26] no provance and test for release --- .gitlab/workflows/devcontainer.yml | 2 -- .gitlab/workflows/release.yml | 27 ++++++++++++++++++++++++--- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/.gitlab/workflows/devcontainer.yml b/.gitlab/workflows/devcontainer.yml index 07ac5435..7dd7244a 100644 --- a/.gitlab/workflows/devcontainer.yml +++ b/.gitlab/workflows/devcontainer.yml @@ -27,7 +27,6 @@ dev-container-publish: --cache-from type=registry,ref=${CI_REGISTRY_IMAGE}/dev-cache:py${PYTHON_VERSION} \ --cache-to type=registry,ref=${CI_REGISTRY_IMAGE}/dev-cache:py${PYTHON_VERSION},mode=max \ --file .devcontainer/Dockerfile \ - --provenance false \ --load \ --tag ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \ --target dev @@ -41,7 +40,6 @@ dev-container-publish: docker buildx build . \ --build-arg PYTHON_VERSION=${PYTHON_VERSION} \ --file .devcontainer/Dockerfile \ - --provenance false \ --push \ --tag ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \ --target dev diff --git a/.gitlab/workflows/release.yml b/.gitlab/workflows/release.yml index b279803a..c8c85b8b 100644 --- a/.gitlab/workflows/release.yml +++ b/.gitlab/workflows/release.yml @@ -58,7 +58,20 @@ container-publish: --cache-from type=registry,ref=${CI_REGISTRY_IMAGE}/dev-cache:py${PYTHON_VERSION} \ --cache-to type=registry,ref=${CI_REGISTRY_IMAGE}/dev-cache:py${PYTHON_VERSION},mode=max \ --file .devcontainer/Dockerfile \ - --provenance false \ + --load \ + --tag ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \ + --tag ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION}-${CI_COMMIT_TAG} \ + --target dev + - | + docker run --rm \ + -e CI_PAGES_URL \ + -v ${PWD}:/workspace \ + ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \ + make dev lint test doc build + - | + docker buildx build . \ + --build-arg PYTHON_VERSION=${PYTHON_VERSION} \ + --file .devcontainer/Dockerfile \ --push \ --tag ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \ --tag ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION}-${CI_COMMIT_TAG} \ @@ -67,9 +80,17 @@ container-publish: docker buildx build . \ --build-arg PDM_BUILD_SCM_VERSION=${CI_COMMIT_TAG} \ --build-arg PYTHON_VERSION=${PYTHON_VERSION} \ - --cache-from type=registry,ref=${CI_REGISTRY_IMAGE}/dev-cache:py${PYTHON_VERSION} \ --file .devcontainer/Dockerfile \ - --provenance false \ + --load \ + --tag ${CI_REGISTRY_IMAGE}:py${PYTHON_VERSION} \ + --tag ${CI_REGISTRY_IMAGE}:py${PYTHON_VERSION}-${CI_COMMIT_TAG} \ + --target prod + - docker run --rm ${CI_REGISTRY_IMAGE}:py${PYTHON_VERSION} + - | + docker buildx build . \ + --build-arg PDM_BUILD_SCM_VERSION=${CI_COMMIT_TAG} \ + --build-arg PYTHON_VERSION=${PYTHON_VERSION} \ + --file .devcontainer/Dockerfile \ --push \ --tag ${CI_REGISTRY_IMAGE}:py${PYTHON_VERSION} \ --tag ${CI_REGISTRY_IMAGE}:py${PYTHON_VERSION}-${CI_COMMIT_TAG} \ From 124e3e9dfc809193127490e7f38c1b9de249e4c9 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 7 May 2024 03:15:28 +0000 Subject: [PATCH 05/26] fix: test release --- .gitlab/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab/workflows/release.yml b/.gitlab/workflows/release.yml index c8c85b8b..616ce0f3 100644 --- a/.gitlab/workflows/release.yml +++ b/.gitlab/workflows/release.yml @@ -117,6 +117,7 @@ pages: needs: - pages-build - release-publish + - container-publish rules: - if: $CI_COMMIT_TAG =~ /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/ script: From 0362a15dcb54f137290187c1de51f2f5720fd206 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 7 May 2024 04:56:45 +0000 Subject: [PATCH 06/26] minor gitlab ci --- .gitlab/workflows/ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitlab/workflows/ci.yml b/.gitlab/workflows/ci.yml index 29ac5f6f..9078b65c 100644 --- a/.gitlab/workflows/ci.yml +++ b/.gitlab/workflows/ci.yml @@ -27,7 +27,10 @@ ci: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' script: - make dev - - make lint test doc build + - make lint + - make test + - make doc + - make build stage: ci consistency: interruptible: true From a0c171f6a1e974b54e43b39b19007d692cd61b2b Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 7 May 2024 05:03:46 +0000 Subject: [PATCH 07/26] update template --- .gitlab/workflows/release.yml | 1 + template/.devcontainer/Dockerfile.jinja | 5 +++- .../workflows/ci.yml.jinja | 5 +++- .../workflows/devcontainer.yml.jinja | 15 +++++++++- .../workflows/release.yml.jinja | 29 +++++++++++++++++-- template/pyproject.toml.jinja | 1 + 6 files changed, 50 insertions(+), 6 deletions(-) diff --git a/.gitlab/workflows/release.yml b/.gitlab/workflows/release.yml index 616ce0f3..33cf1268 100644 --- a/.gitlab/workflows/release.yml +++ b/.gitlab/workflows/release.yml @@ -48,6 +48,7 @@ container-publish: rules: - if: $CI_COMMIT_TAG =~ /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/ script: + - env | sort - docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY} - docker context create builder - docker buildx create builder --name container --driver docker-container --use diff --git a/template/.devcontainer/Dockerfile.jinja b/template/.devcontainer/Dockerfile.jinja index 0b05cd69..e99ba542 100644 --- a/template/.devcontainer/Dockerfile.jinja +++ b/template/.devcontainer/Dockerfile.jinja @@ -50,6 +50,9 @@ RUN groupadd --gid $USER_GID $USERNAME \ # Set permission for related folders RUN chown -R $USER_UID:$USER_GID $PIPX_HOME $PIPX_BIN_DIR +# Set default working directory +WORKDIR /workspace + ######################################################################################## # Build image is an intermediate image used for building the project. ######################################################################################## @@ -62,7 +65,7 @@ COPY src/ /workspace/src # Install dependencies and project into the local packages directory. WORKDIR /workspace -ARG PDM_BUILD_SCM_VERSION=0.0.0 +ARG PDM_BUILD_SCM_VERSION RUN mkdir __pypackages__ && PDM_BUILD_SCM_VERSION=${PDM_BUILD_SCM_VERSION} pdm sync --prod --no-editable ######################################################################################## diff --git a/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/ci.yml.jinja b/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/ci.yml.jinja index f8e5ef16..b3bb34d4 100644 --- a/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/ci.yml.jinja +++ b/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/ci.yml.jinja @@ -38,7 +38,10 @@ ci: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' script: - make dev - - make lint test doc build + - make lint + - make test + - make doc + - make build stage: ci [%- if project_name == 'Serious Scaffold Python' %] consistency: diff --git a/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/devcontainer.yml.jinja b/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/devcontainer.yml.jinja index e8fd1eaa..79ff06d0 100644 --- a/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/devcontainer.yml.jinja +++ b/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/devcontainer.yml.jinja @@ -27,6 +27,7 @@ dev-container-publish: if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push" - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "web" script: + - env | sort - docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY} - docker context create builder - docker buildx create builder --name container --driver docker-container --use @@ -37,7 +38,19 @@ dev-container-publish: --cache-from type=registry,ref=${CI_REGISTRY_IMAGE}/dev-cache:py${PYTHON_VERSION} \ --cache-to type=registry,ref=${CI_REGISTRY_IMAGE}/dev-cache:py${PYTHON_VERSION},mode=max \ --file .devcontainer/Dockerfile \ - --provenance false \ + --load \ + --tag ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \ + --target dev + - | + docker run --rm \ + -e CI_PAGES_URL \ + -v ${PWD}:/workspace \ + ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \ + make dev lint test doc build + - | + docker buildx build . \ + --build-arg PYTHON_VERSION=${PYTHON_VERSION} \ + --file .devcontainer/Dockerfile \ --push \ --tag ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \ --target dev diff --git a/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/release.yml.jinja b/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/release.yml.jinja index eda5da8c..4add994b 100644 --- a/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/release.yml.jinja +++ b/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/release.yml.jinja @@ -59,6 +59,7 @@ container-publish: rules: - if: $CI_COMMIT_TAG =~ /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/ script: + - env | sort - docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY} - docker context create builder - docker buildx create builder --name container --driver docker-container --use @@ -69,7 +70,20 @@ container-publish: --cache-from type=registry,ref=${CI_REGISTRY_IMAGE}/dev-cache:py${PYTHON_VERSION} \ --cache-to type=registry,ref=${CI_REGISTRY_IMAGE}/dev-cache:py${PYTHON_VERSION},mode=max \ --file .devcontainer/Dockerfile \ - --provenance false \ + --load \ + --tag ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \ + --tag ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION}-${CI_COMMIT_TAG} \ + --target dev + - | + docker run --rm \ + -e CI_PAGES_URL \ + -v ${PWD}:/workspace \ + ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \ + make dev lint test doc build + - | + docker buildx build . \ + --build-arg PYTHON_VERSION=${PYTHON_VERSION} \ + --file .devcontainer/Dockerfile \ --push \ --tag ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \ --tag ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION}-${CI_COMMIT_TAG} \ @@ -78,9 +92,17 @@ container-publish: docker buildx build . \ --build-arg PDM_BUILD_SCM_VERSION=${CI_COMMIT_TAG} \ --build-arg PYTHON_VERSION=${PYTHON_VERSION} \ - --cache-from type=registry,ref=${CI_REGISTRY_IMAGE}/dev-cache:py${PYTHON_VERSION} \ --file .devcontainer/Dockerfile \ - --provenance false \ + --load \ + --tag ${CI_REGISTRY_IMAGE}:py${PYTHON_VERSION} \ + --tag ${CI_REGISTRY_IMAGE}:py${PYTHON_VERSION}-${CI_COMMIT_TAG} \ + --target prod + - docker run --rm ${CI_REGISTRY_IMAGE}:py${PYTHON_VERSION} + - | + docker buildx build . \ + --build-arg PDM_BUILD_SCM_VERSION=${CI_COMMIT_TAG} \ + --build-arg PYTHON_VERSION=${PYTHON_VERSION} \ + --file .devcontainer/Dockerfile \ --push \ --tag ${CI_REGISTRY_IMAGE}:py${PYTHON_VERSION} \ --tag ${CI_REGISTRY_IMAGE}:py${PYTHON_VERSION}-${CI_COMMIT_TAG} \ @@ -107,6 +129,7 @@ pages: needs: - pages-build - release-publish + - container-publish rules: - if: $CI_COMMIT_TAG =~ /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/ script: diff --git a/template/pyproject.toml.jinja b/template/pyproject.toml.jinja index 92e1d1b6..1ab9bbf3 100644 --- a/template/pyproject.toml.jinja +++ b/template/pyproject.toml.jinja @@ -139,6 +139,7 @@ test = [ ] [tool.pdm.version] +fallback_version = "0.0.0" source = "scm" [tool.pytest.ini_options] From 0a56da4087c8b835d259959ce34b2af5b3874a62 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 7 May 2024 08:26:49 +0000 Subject: [PATCH 08/26] apply docker test in GitHub Actions --- .github/workflows/devcontainer.yml | 18 ++++++++++++++++- .github/workflows/release.yml | 31 +++++++++++++++++++++++++++--- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/.github/workflows/devcontainer.yml b/.github/workflows/devcontainer.yml index bb29be2c..74484591 100644 --- a/.github/workflows/devcontainer.yml +++ b/.github/workflows/devcontainer.yml @@ -9,6 +9,10 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + - id: pages + name: Setup pages + uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0 + - run: env | sort - run: docker login -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} ghcr.io - run: | docker context create builder @@ -20,7 +24,19 @@ jobs: --cache-from type=registry,ref=ghcr.io/${{ github.repository }}/dev-cache:py${{ matrix.python-version }} \ --cache-to type=registry,ref=ghcr.io/${{ github.repository }}/dev-cache:py${{ matrix.python-version }},mode=max \ --file .devcontainer/Dockerfile \ - --provenance false \ + --load \ + --tag ghcr.io/${{ github.repository }}/dev:py${{ matrix.python-version }} \ + --target dev + - run: | + docker run --rm \ + -e CI_PAGES_URL=${{ steps.pages.outputs.base_url }} \ + -v ${PWD}:/workspace \ + ghcr.io/${{ github.repository }}/dev:py${{ matrix.python-version }} \ + make dev lint test doc build + - run: | + docker buildx build . \ + --build-arg PYTHON_VERSION=${{ matrix.python-version }} \ + --file .devcontainer/Dockerfile \ --push \ --tag ghcr.io/${{ github.repository }}/dev:py${{ matrix.python-version }} \ --target dev diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4b01a2c0..3c3b55dd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -60,6 +60,10 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + - id: pages + name: Setup pages + uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0 + - run: env | sort - run: docker login -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} ghcr.io - run: | docker context create builder @@ -71,7 +75,20 @@ jobs: --cache-from type=registry,ref=ghcr.io/${{ github.repository }}/dev-cache:py${{ matrix.python-version }} \ --cache-to type=registry,ref=ghcr.io/${{ github.repository }}/dev-cache:py${{ matrix.python-version }},mode=max \ --file .devcontainer/Dockerfile \ - --provenance false \ + --load \ + --tag ghcr.io/${{ github.repository }}/dev:py${{ matrix.python-version }} \ + --tag ghcr.io/${{ github.repository }}/dev:py${{ matrix.python-version }}-${{ github.ref_name }} \ + --target dev + - run: | + docker run --rm \ + -e CI_PAGES_URL=${{ steps.pages.outputs.base_url }} \ + -v ${PWD}:/workspace \ + ghcr.io/${{ github.repository }}/dev:py${{ matrix.python-version }} \ + make dev lint test doc build + - run: | + docker buildx build . \ + --build-arg PYTHON_VERSION=${{ matrix.python-version }} \ + --file .devcontainer/Dockerfile \ --push \ --tag ghcr.io/${{ github.repository }}/dev:py${{ matrix.python-version }} \ --tag ghcr.io/${{ github.repository }}/dev:py${{ matrix.python-version }}-${{ github.ref_name }} \ @@ -80,9 +97,17 @@ jobs: docker buildx build . \ --build-arg PDM_BUILD_SCM_VERSION=${{ github.ref_name }} \ --build-arg PYTHON_VERSION=${{ matrix.python-version }} \ - --cache-from type=registry,ref=ghcr.io/${{ github.repository }}/dev-cache:py${{ matrix.python-version }} \ --file .devcontainer/Dockerfile \ - --provenance false \ + --load \ + --tag ghcr.io/${{ github.repository }}:py${{ matrix.python-version }} \ + --tag ghcr.io/${{ github.repository }}:py${{ matrix.python-version }}-${{ github.ref_name }} \ + --target prod + - run: docker run --rm ghcr.io/${{ github.repository }}:py${{ matrix.python-version }} + - run: | + docker buildx build . \ + --build-arg PDM_BUILD_SCM_VERSION=${{ github.ref_name }} \ + --build-arg PYTHON_VERSION=${{ matrix.python-version }} \ + --file .devcontainer/Dockerfile \ --push \ --tag ghcr.io/${{ github.repository }}:py${{ matrix.python-version }} \ --tag ghcr.io/${{ github.repository }}:py${{ matrix.python-version }}-${{ github.ref_name }} \ From cb736231fcbc71c4febb877430accc6f89a45152 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 7 May 2024 08:33:22 +0000 Subject: [PATCH 09/26] update template --- .../workflows/devcontainer.yml.jinja | 18 ++++++++++- .../workflows/release.yml.jinja | 31 +++++++++++++++++-- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/devcontainer.yml.jinja b/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/devcontainer.yml.jinja index 5bb5a774..9cd2bc16 100644 --- a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/devcontainer.yml.jinja +++ b/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/devcontainer.yml.jinja @@ -10,6 +10,10 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + - id: pages + name: Setup pages + uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0 + - run: env | sort - run: docker login -u {{ '${{ github.actor }}' }} -p {{ '${{ secrets.GITHUB_TOKEN }}' }} ghcr.io - run: | docker context create builder @@ -21,7 +25,19 @@ jobs: --cache-from type=registry,ref=ghcr.io/{{ '${{ github.repository }}' }}/dev-cache:py{{ '${{ matrix.python-version }}' }} \ --cache-to type=registry,ref=ghcr.io/{{ '${{ github.repository }}' }}/dev-cache:py{{ '${{ matrix.python-version }}' }},mode=max \ --file .devcontainer/Dockerfile \ - --provenance false \ + --load \ + --tag ghcr.io/{{ '${{ github.repository }}' }}/dev:py{{ '${{ matrix.python-version }}' }} \ + --target dev + - run: | + docker run --rm \ + -e CI_PAGES_URL={{ '${{ steps.pages.outputs.base_url }}' }} \ + -v ${PWD}:/workspace \ + ghcr.io/{{ '${{ github.repository }}' }}/dev:py{{ '${{ matrix.python-version }}' }} \ + make dev lint test doc build + - run: | + docker buildx build . \ + --build-arg PYTHON_VERSION={{ '${{ matrix.python-version }}' }} \ + --file .devcontainer/Dockerfile \ --push \ --tag ghcr.io/{{ '${{ github.repository }}' }}/dev:py{{ '${{ matrix.python-version }}' }} \ --target dev diff --git a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/release.yml.jinja b/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/release.yml.jinja index 67f7f14a..9e2ab3f5 100644 --- a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/release.yml.jinja +++ b/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/release.yml.jinja @@ -61,6 +61,10 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + - id: pages + name: Setup pages + uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0 + - run: env | sort - run: docker login -u {{ '${{ github.actor }}' }} -p {{ '${{ secrets.GITHUB_TOKEN }}' }} ghcr.io - run: | docker context create builder @@ -72,7 +76,20 @@ jobs: --cache-from type=registry,ref=ghcr.io/{{ '${{ github.repository }}' }}/dev-cache:py{{ '${{ matrix.python-version }}' }} \ --cache-to type=registry,ref=ghcr.io/{{ '${{ github.repository }}' }}/dev-cache:py{{ '${{ matrix.python-version }}' }},mode=max \ --file .devcontainer/Dockerfile \ - --provenance false \ + --load \ + --tag ghcr.io/{{ '${{ github.repository }}' }}/dev:py{{ '${{ matrix.python-version }}' }} \ + --tag ghcr.io/{{ '${{ github.repository }}' }}/dev:py{{ '${{ matrix.python-version }}' }}-{{ '${{ github.ref_name }}' }} \ + --target dev + - run: | + docker run --rm \ + -e CI_PAGES_URL={{ '${{ steps.pages.outputs.base_url }}' }} \ + -v ${PWD}:/workspace \ + ghcr.io/{{ '${{ github.repository }}' }}/dev:py{{ '${{ matrix.python-version }}' }} \ + make dev lint test doc build + - run: | + docker buildx build . \ + --build-arg PYTHON_VERSION={{ '${{ matrix.python-version }}' }} \ + --file .devcontainer/Dockerfile \ --push \ --tag ghcr.io/{{ '${{ github.repository }}' }}/dev:py{{ '${{ matrix.python-version }}' }} \ --tag ghcr.io/{{ '${{ github.repository }}' }}/dev:py{{ '${{ matrix.python-version }}' }}-{{ '${{ github.ref_name }}' }} \ @@ -81,9 +98,17 @@ jobs: docker buildx build . \ --build-arg PDM_BUILD_SCM_VERSION={{ '${{ github.ref_name }}' }} \ --build-arg PYTHON_VERSION={{ '${{ matrix.python-version }}' }} \ - --cache-from type=registry,ref=ghcr.io/{{ '${{ github.repository }}' }}/dev-cache:py{{ '${{ matrix.python-version }}' }} \ --file .devcontainer/Dockerfile \ - --provenance false \ + --load \ + --tag ghcr.io/{{ '${{ github.repository }}' }}:py{{ '${{ matrix.python-version }}' }} \ + --tag ghcr.io/{{ '${{ github.repository }}' }}:py{{ '${{ matrix.python-version }}' }}-{{ '${{ github.ref_name }}' }} \ + --target prod + - run: docker run --rm ghcr.io/{{ '${{ github.repository }}' }}:py{{ '${{ matrix.python-version }}' }} + - run: | + docker buildx build . \ + --build-arg PDM_BUILD_SCM_VERSION={{ '${{ github.ref_name }}' }} \ + --build-arg PYTHON_VERSION={{ '${{ matrix.python-version }}' }} \ + --file .devcontainer/Dockerfile \ --push \ --tag ghcr.io/{{ '${{ github.repository }}' }}:py{{ '${{ matrix.python-version }}' }} \ --tag ghcr.io/{{ '${{ github.repository }}' }}:py{{ '${{ matrix.python-version }}' }}-{{ '${{ github.ref_name }}' }} \ From e7dd967b4a4fcf736d2808baf8db5f40d4e18e75 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 7 May 2024 08:58:01 +0000 Subject: [PATCH 10/26] try fix --- .github/workflows/devcontainer.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/devcontainer.yml b/.github/workflows/devcontainer.yml index 74484591..a46d487a 100644 --- a/.github/workflows/devcontainer.yml +++ b/.github/workflows/devcontainer.yml @@ -30,6 +30,7 @@ jobs: - run: | docker run --rm \ -e CI_PAGES_URL=${{ steps.pages.outputs.base_url }} \ + -u 1000:1000 \ -v ${PWD}:/workspace \ ghcr.io/${{ github.repository }}/dev:py${{ matrix.python-version }} \ make dev lint test doc build From b6be1bbae36f7bce5399da775f2a218bc1a561e6 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 7 May 2024 09:04:34 +0000 Subject: [PATCH 11/26] remove redundant env sort --- .gitlab/workflows/devcontainer.yml | 1 - .gitlab/workflows/release.yml | 1 - .../workflows/devcontainer.yml.jinja | 1 - .../workflows/release.yml.jinja | 1 - 4 files changed, 4 deletions(-) diff --git a/.gitlab/workflows/devcontainer.yml b/.gitlab/workflows/devcontainer.yml index 7dd7244a..4e986d48 100644 --- a/.gitlab/workflows/devcontainer.yml +++ b/.gitlab/workflows/devcontainer.yml @@ -16,7 +16,6 @@ dev-container-publish: if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push" - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "web" script: - - env | sort - docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY} - docker context create builder - docker buildx create builder --name container --driver docker-container --use diff --git a/.gitlab/workflows/release.yml b/.gitlab/workflows/release.yml index 33cf1268..616ce0f3 100644 --- a/.gitlab/workflows/release.yml +++ b/.gitlab/workflows/release.yml @@ -48,7 +48,6 @@ container-publish: rules: - if: $CI_COMMIT_TAG =~ /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/ script: - - env | sort - docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY} - docker context create builder - docker buildx create builder --name container --driver docker-container --use diff --git a/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/devcontainer.yml.jinja b/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/devcontainer.yml.jinja index 79ff06d0..1b4b34b9 100644 --- a/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/devcontainer.yml.jinja +++ b/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/devcontainer.yml.jinja @@ -27,7 +27,6 @@ dev-container-publish: if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push" - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "web" script: - - env | sort - docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY} - docker context create builder - docker buildx create builder --name container --driver docker-container --use diff --git a/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/release.yml.jinja b/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/release.yml.jinja index 4add994b..2cc6875b 100644 --- a/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/release.yml.jinja +++ b/template/[% if repo_host_type == 'gitlab.com' or repo_host_type == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/release.yml.jinja @@ -59,7 +59,6 @@ container-publish: rules: - if: $CI_COMMIT_TAG =~ /^v?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-?(a|b|rc)(0|[1-9][0-9]*)?)?$/ script: - - env | sort - docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY} - docker context create builder - docker buildx create builder --name container --driver docker-container --use From 22cc18e137e20b3b931e727558eec85ec5bdd9e0 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 7 May 2024 09:05:09 +0000 Subject: [PATCH 12/26] try fix --- .devcontainer/Dockerfile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index adf569e1..def876b1 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -47,12 +47,12 @@ RUN groupadd --gid $USER_GID $USERNAME \ && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ && chmod 0440 /etc/sudoers.d/$USERNAME -# Set permission for related folders -RUN chown -R $USER_UID:$USER_GID $PIPX_HOME $PIPX_BIN_DIR - # Set default working directory WORKDIR /workspace +# Set permission for related folders +RUN chown -R $USER_UID:$USER_GID $PIPX_HOME $PIPX_BIN_DIR /workspace + ######################################################################################## # Build image is an intermediate image used for building the project. ######################################################################################## @@ -64,7 +64,6 @@ COPY pyproject.toml pdm.lock README.md /workspace/ COPY src/ /workspace/src # Install dependencies and project into the local packages directory. -WORKDIR /workspace ARG PDM_BUILD_SCM_VERSION RUN mkdir __pypackages__ && PDM_BUILD_SCM_VERSION=${PDM_BUILD_SCM_VERSION} pdm sync --prod --no-editable From 09ec67da2f6bb3b543274ec3237af9152d27bb4a Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 7 May 2024 09:23:06 +0000 Subject: [PATCH 13/26] debug --- .github/workflows/devcontainer.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/devcontainer.yml b/.github/workflows/devcontainer.yml index a46d487a..7af78f91 100644 --- a/.github/workflows/devcontainer.yml +++ b/.github/workflows/devcontainer.yml @@ -27,6 +27,19 @@ jobs: --load \ --tag ghcr.io/${{ github.repository }}/dev:py${{ matrix.python-version }} \ --target dev + - run: | + docker run --rm \ + -e CI_PAGES_URL=${{ steps.pages.outputs.base_url }} \ + -v ${PWD}:/workspace \ + ghcr.io/${{ github.repository }}/dev:py${{ matrix.python-version }} \ + ls -al + - run: | + docker run --rm \ + -e CI_PAGES_URL=${{ steps.pages.outputs.base_url }} \ + -u 1000:1000 \ + -v ${PWD}:/workspace \ + ghcr.io/${{ github.repository }}/dev:py${{ matrix.python-version }} \ + ls -al - run: | docker run --rm \ -e CI_PAGES_URL=${{ steps.pages.outputs.base_url }} \ From e83059d86d4ae969b717df0243e24e18770af283 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 7 May 2024 09:30:05 +0000 Subject: [PATCH 14/26] try fix --- .github/workflows/devcontainer.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/devcontainer.yml b/.github/workflows/devcontainer.yml index 7af78f91..69a7f5cc 100644 --- a/.github/workflows/devcontainer.yml +++ b/.github/workflows/devcontainer.yml @@ -36,14 +36,14 @@ jobs: - run: | docker run --rm \ -e CI_PAGES_URL=${{ steps.pages.outputs.base_url }} \ - -u 1000:1000 \ + -u $(id -u):$(id -g) \ -v ${PWD}:/workspace \ ghcr.io/${{ github.repository }}/dev:py${{ matrix.python-version }} \ ls -al - run: | docker run --rm \ -e CI_PAGES_URL=${{ steps.pages.outputs.base_url }} \ - -u 1000:1000 \ + -u $(id -u):$(id -g) \ -v ${PWD}:/workspace \ ghcr.io/${{ github.repository }}/dev:py${{ matrix.python-version }} \ make dev lint test doc build From 17d5700be6436796932fa2e9f6416b829d8c5ce7 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 7 May 2024 09:34:11 +0000 Subject: [PATCH 15/26] debug --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e0f774f5..bd202dcb 100644 --- a/Makefile +++ b/Makefile @@ -53,7 +53,7 @@ dev-%: # Prepare the development environment. # Install the pacakge in editable mode with all optional dependencies and pre-commit hoook. dev: - pdm install + pdm install -v if [ "$(CI)" != "true" ] && command -v pre-commit > /dev/null 2>&1; then pre-commit install; fi ######################################################################################## From 780c4cbe4516c71215cb53612cd12ff446abf88e Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 7 May 2024 09:44:12 +0000 Subject: [PATCH 16/26] revert --- .devcontainer/Dockerfile | 6 +++--- .github/workflows/devcontainer.yml | 14 -------------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index def876b1..08cd691e 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -47,12 +47,12 @@ RUN groupadd --gid $USER_GID $USERNAME \ && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ && chmod 0440 /etc/sudoers.d/$USERNAME +# Set permission for related folders +RUN chown -R $USER_UID:$USER_GID $PIPX_HOME $PIPX_BIN_DIR + # Set default working directory WORKDIR /workspace -# Set permission for related folders -RUN chown -R $USER_UID:$USER_GID $PIPX_HOME $PIPX_BIN_DIR /workspace - ######################################################################################## # Build image is an intermediate image used for building the project. ######################################################################################## diff --git a/.github/workflows/devcontainer.yml b/.github/workflows/devcontainer.yml index 69a7f5cc..74484591 100644 --- a/.github/workflows/devcontainer.yml +++ b/.github/workflows/devcontainer.yml @@ -32,20 +32,6 @@ jobs: -e CI_PAGES_URL=${{ steps.pages.outputs.base_url }} \ -v ${PWD}:/workspace \ ghcr.io/${{ github.repository }}/dev:py${{ matrix.python-version }} \ - ls -al - - run: | - docker run --rm \ - -e CI_PAGES_URL=${{ steps.pages.outputs.base_url }} \ - -u $(id -u):$(id -g) \ - -v ${PWD}:/workspace \ - ghcr.io/${{ github.repository }}/dev:py${{ matrix.python-version }} \ - ls -al - - run: | - docker run --rm \ - -e CI_PAGES_URL=${{ steps.pages.outputs.base_url }} \ - -u $(id -u):$(id -g) \ - -v ${PWD}:/workspace \ - ghcr.io/${{ github.repository }}/dev:py${{ matrix.python-version }} \ make dev lint test doc build - run: | docker buildx build . \ From 64cf10b51b33467c973a7137121750c8b51f81eb Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 14 May 2024 13:25:06 +0800 Subject: [PATCH 17/26] update template --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index fc3834b8..896028f2 100644 --- a/Makefile +++ b/Makefile @@ -53,7 +53,7 @@ dev-%: # Prepare the development environment. # Install the pacakge in editable mode with all optional dependencies and pre-commit hoook. dev: - pdm install -v + pdm install if [ "$(CI)" != "true" ] && command -v pre-commit > /dev/null 2>&1; then pre-commit install; fi ######################################################################################## From 3efbf0f2b79433bdd848921e8d184c41f7167d2f Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Tue, 14 May 2024 14:00:40 +0800 Subject: [PATCH 18/26] test container in pull request --- .github/workflows/ci.yml | 3 --- .github/workflows/devcontainer.yml | 9 +++++++++ .../workflows/ci.yml.jinja | 3 --- .../workflows/devcontainer.yml.jinja | 9 +++++++++ 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index baf7c703..2f3eba01 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,9 +71,6 @@ jobs: - run: test -z "$(git status --porcelain)" on: pull_request: - types: - - opened - - synchronize push: branches: - main diff --git a/.github/workflows/devcontainer.yml b/.github/workflows/devcontainer.yml index f607c1fa..0efb09f9 100644 --- a/.github/workflows/devcontainer.yml +++ b/.github/workflows/devcontainer.yml @@ -34,6 +34,15 @@ jobs: ghcr.io/${{ github.repository }}/dev:py${{ matrix.python-version }} \ make dev lint test doc build - run: | + docker buildx build . \ + --build-arg PYTHON_VERSION=${{ matrix.python-version }} \ + --file .devcontainer/Dockerfile \ + --load \ + --tag ghcr.io/${{ github.repository }}:py${{ matrix.python-version }} \ + --target prod + - run: docker run --rm ghcr.io/${{ github.repository }}:py${{ matrix.python-version }} + - if: github.event_name != 'pull_request' + run: | docker buildx build . \ --build-arg PYTHON_VERSION=${{ matrix.python-version }} \ --file .devcontainer/Dockerfile \ diff --git a/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/ci.yml.jinja b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/ci.yml.jinja index 2b93a31b..b2f74ddd 100644 --- a/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/ci.yml.jinja +++ b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/ci.yml.jinja @@ -100,9 +100,6 @@ jobs: [%- endif %] on: pull_request: - types: - - opened - - synchronize push: branches: - main diff --git a/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/devcontainer.yml.jinja b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/devcontainer.yml.jinja index 83fb8916..f2a27f91 100644 --- a/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/devcontainer.yml.jinja +++ b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/devcontainer.yml.jinja @@ -35,6 +35,15 @@ jobs: ghcr.io/{{ '${{ github.repository }}' }}/dev:py{{ '${{ matrix.python-version }}' }} \ make dev lint test doc build - run: | + docker buildx build . \ + --build-arg PYTHON_VERSION={{ '${{ matrix.python-version }}' }} \ + --file .devcontainer/Dockerfile \ + --load \ + --tag ghcr.io/{{ '${{ github.repository }}' }}:py{{ '${{ matrix.python-version }}' }} \ + --target prod + - run: docker run --rm ghcr.io/{{ '${{ github.repository }}' }}:py{{ '${{ matrix.python-version }}' }} + - if: github.event_name != 'pull_request' + run: | docker buildx build . \ --build-arg PYTHON_VERSION={{ '${{ matrix.python-version }}' }} \ --file .devcontainer/Dockerfile \ From 05750c6618124c0c2c70e6deed7465435102e73d Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Fri, 24 May 2024 09:43:02 +0800 Subject: [PATCH 19/26] Remove CI_PAGES_URL --- .github/workflows/devcontainer.yml | 1 - .github/workflows/release.yml | 1 - .gitlab/workflows/devcontainer.yml | 1 - .gitlab/workflows/release.yml | 1 - .../workflows/devcontainer.yml.jinja | 1 - .../workflows/release.yml.jinja | 1 - .../workflows/devcontainer.yml.jinja | 1 - .../workflows/release.yml.jinja | 1 - 8 files changed, 8 deletions(-) diff --git a/.github/workflows/devcontainer.yml b/.github/workflows/devcontainer.yml index f9596027..2fbd278c 100644 --- a/.github/workflows/devcontainer.yml +++ b/.github/workflows/devcontainer.yml @@ -26,7 +26,6 @@ jobs: --target dev - run: | docker run --rm \ - -e CI_PAGES_URL=${{ steps.pages.outputs.base_url }} \ -v ${PWD}:/workspace \ ghcr.io/${{ github.repository }}/dev:py${{ matrix.python-version }} \ make dev lint test doc build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7f8af196..320928e2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -63,7 +63,6 @@ jobs: --target dev - run: | docker run --rm \ - -e CI_PAGES_URL=${{ steps.pages.outputs.base_url }} \ -v ${PWD}:/workspace \ ghcr.io/${{ github.repository }}/dev:py${{ matrix.python-version }} \ make dev lint test doc build diff --git a/.gitlab/workflows/devcontainer.yml b/.gitlab/workflows/devcontainer.yml index 5a11f31a..273c7651 100644 --- a/.gitlab/workflows/devcontainer.yml +++ b/.gitlab/workflows/devcontainer.yml @@ -31,7 +31,6 @@ dev-container-publish: --target dev - | docker run --rm \ - -e CI_PAGES_URL \ -v ${PWD}:/workspace \ ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \ make dev lint test doc build diff --git a/.gitlab/workflows/release.yml b/.gitlab/workflows/release.yml index 1295f235..cc1c431b 100644 --- a/.gitlab/workflows/release.yml +++ b/.gitlab/workflows/release.yml @@ -58,7 +58,6 @@ container-publish: --target dev - | docker run --rm \ - -e CI_PAGES_URL \ -v ${PWD}:/workspace \ ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \ make dev lint test doc build diff --git a/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/devcontainer.yml.jinja b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/devcontainer.yml.jinja index d802db9b..41779b4f 100644 --- a/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/devcontainer.yml.jinja +++ b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/devcontainer.yml.jinja @@ -27,7 +27,6 @@ jobs: --target dev - run: | docker run --rm \ - -e CI_PAGES_URL={{ '${{ steps.pages.outputs.base_url }}' }} \ -v ${PWD}:/workspace \ ghcr.io/{{ '${{ github.repository }}' }}/dev:py{{ '${{ matrix.python-version }}' }} \ make dev lint test doc build diff --git a/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/release.yml.jinja b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/release.yml.jinja index 78aa5e7f..cf998be5 100644 --- a/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/release.yml.jinja +++ b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/release.yml.jinja @@ -64,7 +64,6 @@ jobs: --target dev - run: | docker run --rm \ - -e CI_PAGES_URL={{ '${{ steps.pages.outputs.base_url }}' }} \ -v ${PWD}:/workspace \ ghcr.io/{{ '${{ github.repository }}' }}/dev:py{{ '${{ matrix.python-version }}' }} \ make dev lint test doc build diff --git a/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/devcontainer.yml.jinja b/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/devcontainer.yml.jinja index 9e465c05..34f55268 100644 --- a/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/devcontainer.yml.jinja +++ b/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/devcontainer.yml.jinja @@ -42,7 +42,6 @@ dev-container-publish: --target dev - | docker run --rm \ - -e CI_PAGES_URL \ -v ${PWD}:/workspace \ ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \ make dev lint test doc build diff --git a/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/release.yml.jinja b/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/release.yml.jinja index 86890a16..d543246b 100644 --- a/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/release.yml.jinja +++ b/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/release.yml.jinja @@ -69,7 +69,6 @@ container-publish: --target dev - | docker run --rm \ - -e CI_PAGES_URL \ -v ${PWD}:/workspace \ ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \ make dev lint test doc build From 5f2ff03fa96ad4d4ce3043c4b40ab1b169a3e453 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Fri, 24 May 2024 09:47:34 +0800 Subject: [PATCH 20/26] Merge ci related operations together to avoid run test twice --- .github/workflows/ci.yml | 5 +---- .gitlab/workflows/ci.yml | 5 +---- .../workflows/ci.yml.jinja | 5 +---- .../workflows/ci.yml.jinja | 5 +---- 4 files changed, 4 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 326c7d25..952109de 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,10 +28,7 @@ jobs: version: 2.15.2 - run: env | sort - run: make dev - - run: make lint - - run: make test - - run: make doc - - run: make build + - run: make lint test doc build strategy: matrix: os: diff --git a/.gitlab/workflows/ci.yml b/.gitlab/workflows/ci.yml index 385b0820..60b04793 100644 --- a/.gitlab/workflows/ci.yml +++ b/.gitlab/workflows/ci.yml @@ -27,10 +27,7 @@ ci: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' script: - make dev - - make lint - - make test - - make doc - - make build + - make lint test doc build stage: ci consistency: interruptible: true diff --git a/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/ci.yml.jinja b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/ci.yml.jinja index 8d77feb5..94dcafbe 100644 --- a/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/ci.yml.jinja +++ b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/ci.yml.jinja @@ -29,10 +29,7 @@ jobs: version: 2.15.2 - run: env | sort - run: make dev - - run: make lint - - run: make test - - run: make doc - - run: make build + - run: make lint test doc build strategy: matrix: os: diff --git a/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/ci.yml.jinja b/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/ci.yml.jinja index 53411f00..ec280bc5 100644 --- a/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/ci.yml.jinja +++ b/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/ci.yml.jinja @@ -38,10 +38,7 @@ ci: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' script: - make dev - - make lint - - make test - - make doc - - make build + - make lint test doc build stage: ci [%- if project_name == 'Serious Scaffold Python' %] consistency: From 856997a86150afb88d873208a551f2e0c988bb7e Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Fri, 24 May 2024 09:48:30 +0800 Subject: [PATCH 21/26] revert formater changes --- .github/workflows/devcontainer.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/devcontainer.yml b/.github/workflows/devcontainer.yml index 2fbd278c..dc3f7d09 100644 --- a/.github/workflows/devcontainer.yml +++ b/.github/workflows/devcontainer.yml @@ -48,11 +48,11 @@ jobs: strategy: matrix: python-version: - - '3.8' - - '3.9' - - '3.10' - - '3.11' - - '3.12' + - "3.8" + - "3.9" + - "3.10" + - "3.11" + - "3.12" on: push: branches: From 53bc5f156f880a412581c8d6cd50156035bfab38 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Fri, 24 May 2024 10:02:36 +0800 Subject: [PATCH 22/26] fix ci --- .github/workflows/devcontainer.yml | 1 + .github/workflows/release.yml | 1 + .gitlab/workflows/devcontainer.yml | 1 + .gitlab/workflows/release.yml | 1 + .../workflows/devcontainer.yml.jinja | 1 + .../workflows/release.yml.jinja | 1 + .../workflows/devcontainer.yml.jinja | 1 + .../workflows/release.yml.jinja | 1 + 8 files changed, 8 insertions(+) diff --git a/.github/workflows/devcontainer.yml b/.github/workflows/devcontainer.yml index dc3f7d09..d37e1913 100644 --- a/.github/workflows/devcontainer.yml +++ b/.github/workflows/devcontainer.yml @@ -26,6 +26,7 @@ jobs: --target dev - run: | docker run --rm \ + -e CI=true \ -v ${PWD}:/workspace \ ghcr.io/${{ github.repository }}/dev:py${{ matrix.python-version }} \ make dev lint test doc build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 320928e2..92c2c4d2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -63,6 +63,7 @@ jobs: --target dev - run: | docker run --rm \ + -e CI=true \ -v ${PWD}:/workspace \ ghcr.io/${{ github.repository }}/dev:py${{ matrix.python-version }} \ make dev lint test doc build diff --git a/.gitlab/workflows/devcontainer.yml b/.gitlab/workflows/devcontainer.yml index 273c7651..d79303f2 100644 --- a/.gitlab/workflows/devcontainer.yml +++ b/.gitlab/workflows/devcontainer.yml @@ -31,6 +31,7 @@ dev-container-publish: --target dev - | docker run --rm \ + -e CI=true \ -v ${PWD}:/workspace \ ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \ make dev lint test doc build diff --git a/.gitlab/workflows/release.yml b/.gitlab/workflows/release.yml index cc1c431b..974088e7 100644 --- a/.gitlab/workflows/release.yml +++ b/.gitlab/workflows/release.yml @@ -58,6 +58,7 @@ container-publish: --target dev - | docker run --rm \ + -e CI=true \ -v ${PWD}:/workspace \ ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \ make dev lint test doc build diff --git a/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/devcontainer.yml.jinja b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/devcontainer.yml.jinja index 41779b4f..b5d71bf4 100644 --- a/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/devcontainer.yml.jinja +++ b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/devcontainer.yml.jinja @@ -27,6 +27,7 @@ jobs: --target dev - run: | docker run --rm \ + -e CI=true \ -v ${PWD}:/workspace \ ghcr.io/{{ '${{ github.repository }}' }}/dev:py{{ '${{ matrix.python-version }}' }} \ make dev lint test doc build diff --git a/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/release.yml.jinja b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/release.yml.jinja index cf998be5..e42f963e 100644 --- a/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/release.yml.jinja +++ b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/release.yml.jinja @@ -64,6 +64,7 @@ jobs: --target dev - run: | docker run --rm \ + -e CI=true \ -v ${PWD}:/workspace \ ghcr.io/{{ '${{ github.repository }}' }}/dev:py{{ '${{ matrix.python-version }}' }} \ make dev lint test doc build diff --git a/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/devcontainer.yml.jinja b/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/devcontainer.yml.jinja index 34f55268..c22b9b2a 100644 --- a/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/devcontainer.yml.jinja +++ b/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/devcontainer.yml.jinja @@ -42,6 +42,7 @@ dev-container-publish: --target dev - | docker run --rm \ + -e CI=true \ -v ${PWD}:/workspace \ ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \ make dev lint test doc build diff --git a/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/release.yml.jinja b/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/release.yml.jinja index d543246b..511c4e3c 100644 --- a/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/release.yml.jinja +++ b/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/release.yml.jinja @@ -69,6 +69,7 @@ container-publish: --target dev - | docker run --rm \ + -e CI=true \ -v ${PWD}:/workspace \ ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \ make dev lint test doc build From 5fdefbc25456688ba1b11f2b17f2c7506a013a6c Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Fri, 24 May 2024 10:41:56 +0800 Subject: [PATCH 23/26] trigger devcontainer test on pull request --- .github/workflows/ci.yml | 3 -- .github/workflows/devcontainer.yml | 32 +++++++++++-------- .../workflows/ci.yml.jinja | 3 -- .../workflows/devcontainer.yml.jinja | 32 +++++++++++-------- 4 files changed, 36 insertions(+), 34 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 952109de..a60cc2c9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,9 +2,6 @@ name: CI on: pull_request: - types: - - opened - - synchronize push: branches: - main diff --git a/.github/workflows/devcontainer.yml b/.github/workflows/devcontainer.yml index d37e1913..18160ce9 100644 --- a/.github/workflows/devcontainer.yml +++ b/.github/workflows/devcontainer.yml @@ -1,7 +1,20 @@ name: DevContainer + +on: + pull_request: + push: + branches: + - main + paths: + - .devcontainer/Dockerfile + - .devcontainer/Dockerfile.dockerignore + - .github/workflows/devcontainer.yml + workflow_dispatch: null + concurrency: cancel-in-progress: true group: ${{ github.workflow }}-${{ github.ref }} + jobs: dev-container-publish: permissions: @@ -49,17 +62,8 @@ jobs: strategy: matrix: python-version: - - "3.8" - - "3.9" - - "3.10" - - "3.11" - - "3.12" -on: - push: - branches: - - main - paths: - - .devcontainer/Dockerfile - - .devcontainer/Dockerfile.dockerignore - - .github/workflows/devcontainer.yml - workflow_dispatch: null + - '3.8' + - '3.9' + - '3.10' + - '3.11' + - '3.12' diff --git a/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/ci.yml.jinja b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/ci.yml.jinja index 94dcafbe..ccb1d762 100644 --- a/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/ci.yml.jinja +++ b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/ci.yml.jinja @@ -3,9 +3,6 @@ name: CI on: pull_request: - types: - - opened - - synchronize push: branches: - main diff --git a/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/devcontainer.yml.jinja b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/devcontainer.yml.jinja index b5d71bf4..7a2ed528 100644 --- a/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/devcontainer.yml.jinja +++ b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/devcontainer.yml.jinja @@ -1,8 +1,21 @@ [% from pathjoin("includes", "version_compare.jinja") import version_between -%] name: DevContainer + +on: + pull_request: + push: + branches: + - main + paths: + - .devcontainer/Dockerfile + - .devcontainer/Dockerfile.dockerignore + - .github/workflows/devcontainer.yml + workflow_dispatch: null + concurrency: cancel-in-progress: true group: {{ '${{ github.workflow }}-${{ github.ref }}' }} + jobs: dev-container-publish: permissions: @@ -51,26 +64,17 @@ jobs: matrix: python-version: [%- if version_between("3.8", min_py, max_py) %] - - "3.8" + - '3.8' [%- endif %] [%- if version_between("3.9", min_py, max_py) %] - - "3.9" + - '3.9' [%- endif %] [%- if version_between("3.10", min_py, max_py) %] - - "3.10" + - '3.10' [%- endif %] [%- if version_between("3.11", min_py, max_py) %] - - "3.11" + - '3.11' [%- endif %] [%- if version_between("3.12", min_py, max_py) %] - - "3.12" + - '3.12' [%- endif %] -on: - push: - branches: - - main - paths: - - .devcontainer/Dockerfile - - .devcontainer/Dockerfile.dockerignore - - .github/workflows/devcontainer.yml - workflow_dispatch: null From e6155ddf4320a5addc024e4256cccb46ae819723 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Fri, 24 May 2024 10:47:14 +0800 Subject: [PATCH 24/26] push cache when push --- .github/workflows/devcontainer.yml | 2 +- .github/workflows/release.yml | 2 +- .gitlab/workflows/devcontainer.yml | 2 +- .gitlab/workflows/release.yml | 2 +- .../workflows/devcontainer.yml.jinja | 2 +- .../workflows/release.yml.jinja | 2 +- .../workflows/devcontainer.yml.jinja | 2 +- .../workflows/release.yml.jinja | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/devcontainer.yml b/.github/workflows/devcontainer.yml index 18160ce9..a08710b4 100644 --- a/.github/workflows/devcontainer.yml +++ b/.github/workflows/devcontainer.yml @@ -32,7 +32,6 @@ jobs: docker buildx build . \ --build-arg PYTHON_VERSION=${{ matrix.python-version }} \ --cache-from type=registry,ref=ghcr.io/${{ github.repository }}/dev-cache:py${{ matrix.python-version }} \ - --cache-to type=registry,ref=ghcr.io/${{ github.repository }}/dev-cache:py${{ matrix.python-version }},mode=max \ --file .devcontainer/Dockerfile \ --load \ --tag ghcr.io/${{ github.repository }}/dev:py${{ matrix.python-version }} \ @@ -55,6 +54,7 @@ jobs: run: | docker buildx build . \ --build-arg PYTHON_VERSION=${{ matrix.python-version }} \ + --cache-to type=registry,ref=ghcr.io/${{ github.repository }}/dev-cache:py${{ matrix.python-version }},mode=max \ --file .devcontainer/Dockerfile \ --push \ --tag ghcr.io/${{ github.repository }}/dev:py${{ matrix.python-version }} \ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 92c2c4d2..52d19460 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -55,7 +55,6 @@ jobs: docker buildx build . \ --build-arg PYTHON_VERSION=${{ matrix.python-version }} \ --cache-from type=registry,ref=ghcr.io/${{ github.repository }}/dev-cache:py${{ matrix.python-version }} \ - --cache-to type=registry,ref=ghcr.io/${{ github.repository }}/dev-cache:py${{ matrix.python-version }},mode=max \ --file .devcontainer/Dockerfile \ --load \ --tag ghcr.io/${{ github.repository }}/dev:py${{ matrix.python-version }} \ @@ -70,6 +69,7 @@ jobs: - run: | docker buildx build . \ --build-arg PYTHON_VERSION=${{ matrix.python-version }} \ + --cache-to type=registry,ref=ghcr.io/${{ github.repository }}/dev-cache:py${{ matrix.python-version }},mode=max \ --file .devcontainer/Dockerfile \ --push \ --tag ghcr.io/${{ github.repository }}/dev:py${{ matrix.python-version }} \ diff --git a/.gitlab/workflows/devcontainer.yml b/.gitlab/workflows/devcontainer.yml index d79303f2..82ef9b37 100644 --- a/.gitlab/workflows/devcontainer.yml +++ b/.gitlab/workflows/devcontainer.yml @@ -24,7 +24,6 @@ dev-container-publish: docker buildx build . \ --build-arg PYTHON_VERSION=${PYTHON_VERSION} \ --cache-from type=registry,ref=${CI_REGISTRY_IMAGE}/dev-cache:py${PYTHON_VERSION} \ - --cache-to type=registry,ref=${CI_REGISTRY_IMAGE}/dev-cache:py${PYTHON_VERSION},mode=max \ --file .devcontainer/Dockerfile \ --load \ --tag ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \ @@ -38,6 +37,7 @@ dev-container-publish: - | docker buildx build . \ --build-arg PYTHON_VERSION=${PYTHON_VERSION} \ + --cache-to type=registry,ref=${CI_REGISTRY_IMAGE}/dev-cache:py${PYTHON_VERSION},mode=max \ --file .devcontainer/Dockerfile \ --push \ --tag ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \ diff --git a/.gitlab/workflows/release.yml b/.gitlab/workflows/release.yml index 974088e7..939343fa 100644 --- a/.gitlab/workflows/release.yml +++ b/.gitlab/workflows/release.yml @@ -50,7 +50,6 @@ container-publish: docker buildx build . \ --build-arg PYTHON_VERSION=${PYTHON_VERSION} \ --cache-from type=registry,ref=${CI_REGISTRY_IMAGE}/dev-cache:py${PYTHON_VERSION} \ - --cache-to type=registry,ref=${CI_REGISTRY_IMAGE}/dev-cache:py${PYTHON_VERSION},mode=max \ --file .devcontainer/Dockerfile \ --load \ --tag ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \ @@ -65,6 +64,7 @@ container-publish: - | docker buildx build . \ --build-arg PYTHON_VERSION=${PYTHON_VERSION} \ + --cache-to type=registry,ref=${CI_REGISTRY_IMAGE}/dev-cache:py${PYTHON_VERSION},mode=max \ --file .devcontainer/Dockerfile \ --push \ --tag ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \ diff --git a/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/devcontainer.yml.jinja b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/devcontainer.yml.jinja index 7a2ed528..2ec7ad88 100644 --- a/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/devcontainer.yml.jinja +++ b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/devcontainer.yml.jinja @@ -33,7 +33,6 @@ jobs: docker buildx build . \ --build-arg PYTHON_VERSION={{ '${{ matrix.python-version }}' }} \ --cache-from type=registry,ref=ghcr.io/{{ '${{ github.repository }}' }}/dev-cache:py{{ '${{ matrix.python-version }}' }} \ - --cache-to type=registry,ref=ghcr.io/{{ '${{ github.repository }}' }}/dev-cache:py{{ '${{ matrix.python-version }}' }},mode=max \ --file .devcontainer/Dockerfile \ --load \ --tag ghcr.io/{{ '${{ github.repository }}' }}/dev:py{{ '${{ matrix.python-version }}' }} \ @@ -56,6 +55,7 @@ jobs: run: | docker buildx build . \ --build-arg PYTHON_VERSION={{ '${{ matrix.python-version }}' }} \ + --cache-to type=registry,ref=ghcr.io/{{ '${{ github.repository }}' }}/dev-cache:py{{ '${{ matrix.python-version }}' }},mode=max \ --file .devcontainer/Dockerfile \ --push \ --tag ghcr.io/{{ '${{ github.repository }}' }}/dev:py{{ '${{ matrix.python-version }}' }} \ diff --git a/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/release.yml.jinja b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/release.yml.jinja index e42f963e..156023ea 100644 --- a/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/release.yml.jinja +++ b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/release.yml.jinja @@ -56,7 +56,6 @@ jobs: docker buildx build . \ --build-arg PYTHON_VERSION={{ '${{ matrix.python-version }}' }} \ --cache-from type=registry,ref=ghcr.io/{{ '${{ github.repository }}' }}/dev-cache:py{{ '${{ matrix.python-version }}' }} \ - --cache-to type=registry,ref=ghcr.io/{{ '${{ github.repository }}' }}/dev-cache:py{{ '${{ matrix.python-version }}' }},mode=max \ --file .devcontainer/Dockerfile \ --load \ --tag ghcr.io/{{ '${{ github.repository }}' }}/dev:py{{ '${{ matrix.python-version }}' }} \ @@ -71,6 +70,7 @@ jobs: - run: | docker buildx build . \ --build-arg PYTHON_VERSION={{ '${{ matrix.python-version }}' }} \ + --cache-to type=registry,ref=ghcr.io/{{ '${{ github.repository }}' }}/dev-cache:py{{ '${{ matrix.python-version }}' }},mode=max \ --file .devcontainer/Dockerfile \ --push \ --tag ghcr.io/{{ '${{ github.repository }}' }}/dev:py{{ '${{ matrix.python-version }}' }} \ diff --git a/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/devcontainer.yml.jinja b/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/devcontainer.yml.jinja index c22b9b2a..d3a975b4 100644 --- a/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/devcontainer.yml.jinja +++ b/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/devcontainer.yml.jinja @@ -35,7 +35,6 @@ dev-container-publish: docker buildx build . \ --build-arg PYTHON_VERSION=${PYTHON_VERSION} \ --cache-from type=registry,ref=${CI_REGISTRY_IMAGE}/dev-cache:py${PYTHON_VERSION} \ - --cache-to type=registry,ref=${CI_REGISTRY_IMAGE}/dev-cache:py${PYTHON_VERSION},mode=max \ --file .devcontainer/Dockerfile \ --load \ --tag ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \ @@ -49,6 +48,7 @@ dev-container-publish: - | docker buildx build . \ --build-arg PYTHON_VERSION=${PYTHON_VERSION} \ + --cache-to type=registry,ref=${CI_REGISTRY_IMAGE}/dev-cache:py${PYTHON_VERSION},mode=max \ --file .devcontainer/Dockerfile \ --push \ --tag ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \ diff --git a/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/release.yml.jinja b/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/release.yml.jinja index 511c4e3c..8f49bfe1 100644 --- a/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/release.yml.jinja +++ b/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/release.yml.jinja @@ -61,7 +61,6 @@ container-publish: docker buildx build . \ --build-arg PYTHON_VERSION=${PYTHON_VERSION} \ --cache-from type=registry,ref=${CI_REGISTRY_IMAGE}/dev-cache:py${PYTHON_VERSION} \ - --cache-to type=registry,ref=${CI_REGISTRY_IMAGE}/dev-cache:py${PYTHON_VERSION},mode=max \ --file .devcontainer/Dockerfile \ --load \ --tag ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \ @@ -76,6 +75,7 @@ container-publish: - | docker buildx build . \ --build-arg PYTHON_VERSION=${PYTHON_VERSION} \ + --cache-to type=registry,ref=${CI_REGISTRY_IMAGE}/dev-cache:py${PYTHON_VERSION},mode=max \ --file .devcontainer/Dockerfile \ --push \ --tag ${CI_REGISTRY_IMAGE}/dev:py${PYTHON_VERSION} \ From ab0b324a11b289119596f9ceed1e3cbf32187f9a Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Fri, 24 May 2024 10:48:03 +0800 Subject: [PATCH 25/26] Change PDM_BUILD_SCM_VERSION to SCM_VERSION --- .github/workflows/release.yml | 2 +- .gitlab/workflows/release.yml | 2 +- .../workflows/release.yml.jinja | 2 +- .../workflows/release.yml.jinja | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 52d19460..0856b17d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -87,7 +87,7 @@ jobs: - run: docker run --rm ghcr.io/${{ github.repository }}:py${{ matrix.python-version }} - run: | docker buildx build . \ - --build-arg PDM_BUILD_SCM_VERSION=${{ github.ref_name }} \ + --build-arg SCM_VERSION=${{ github.ref_name }} \ --build-arg PYTHON_VERSION=${{ matrix.python-version }} \ --file .devcontainer/Dockerfile \ --push \ diff --git a/.gitlab/workflows/release.yml b/.gitlab/workflows/release.yml index 939343fa..5f099bc9 100644 --- a/.gitlab/workflows/release.yml +++ b/.gitlab/workflows/release.yml @@ -82,7 +82,7 @@ container-publish: - docker run --rm ${CI_REGISTRY_IMAGE}:py${PYTHON_VERSION} - | docker buildx build . \ - --build-arg PDM_BUILD_SCM_VERSION=${CI_COMMIT_TAG} \ + --build-arg SCM_VERSION=${CI_COMMIT_TAG} \ --build-arg PYTHON_VERSION=${PYTHON_VERSION} \ --file .devcontainer/Dockerfile \ --push \ diff --git a/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/release.yml.jinja b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/release.yml.jinja index 156023ea..a27d9ef7 100644 --- a/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/release.yml.jinja +++ b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/release.yml.jinja @@ -88,7 +88,7 @@ jobs: - run: docker run --rm ghcr.io/{{ '${{ github.repository }}' }}:py{{ '${{ matrix.python-version }}' }} - run: | docker buildx build . \ - --build-arg PDM_BUILD_SCM_VERSION={{ '${{ github.ref_name }}' }} \ + --build-arg SCM_VERSION={{ '${{ github.ref_name }}' }} \ --build-arg PYTHON_VERSION={{ '${{ matrix.python-version }}' }} \ --file .devcontainer/Dockerfile \ --push \ diff --git a/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/release.yml.jinja b/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/release.yml.jinja index 8f49bfe1..aebaeb52 100644 --- a/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/release.yml.jinja +++ b/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/release.yml.jinja @@ -93,7 +93,7 @@ container-publish: - docker run --rm ${CI_REGISTRY_IMAGE}:py${PYTHON_VERSION} - | docker buildx build . \ - --build-arg PDM_BUILD_SCM_VERSION=${CI_COMMIT_TAG} \ + --build-arg SCM_VERSION=${CI_COMMIT_TAG} \ --build-arg PYTHON_VERSION=${PYTHON_VERSION} \ --file .devcontainer/Dockerfile \ --push \ From 4587fa7d5fd5646b87af352b7ad77c90aaf1b0fd Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Fri, 24 May 2024 11:07:24 +0800 Subject: [PATCH 26/26] fix the ci event --- .github/workflows/devcontainer.yml | 4 ++++ .gitlab/workflows/devcontainer.yml | 5 +++++ .../workflows/devcontainer.yml.jinja | 4 ++++ .../workflows/devcontainer.yml.jinja | 5 +++++ 4 files changed, 18 insertions(+) diff --git a/.github/workflows/devcontainer.yml b/.github/workflows/devcontainer.yml index a08710b4..9b574802 100644 --- a/.github/workflows/devcontainer.yml +++ b/.github/workflows/devcontainer.yml @@ -2,6 +2,10 @@ name: DevContainer on: pull_request: + paths: + - .devcontainer/Dockerfile + - .devcontainer/Dockerfile.dockerignore + - .github/workflows/devcontainer.yml push: branches: - main diff --git a/.gitlab/workflows/devcontainer.yml b/.gitlab/workflows/devcontainer.yml index 82ef9b37..fe4b3ea2 100644 --- a/.gitlab/workflows/devcontainer.yml +++ b/.gitlab/workflows/devcontainer.yml @@ -15,6 +15,11 @@ dev-container-publish: - .gitlab/workflows/devcontainer.yml if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push" - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "web" + - changes: + - .devcontainer/Dockerfile + - .devcontainer/Dockerfile.dockerignore + - .gitlab/workflows/devcontainer.yml + if: $CI_PIPELINE_SOURCE == 'merge_request_event' script: - docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY} - docker context create builder diff --git a/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/devcontainer.yml.jinja b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/devcontainer.yml.jinja index 2ec7ad88..4fbeb221 100644 --- a/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/devcontainer.yml.jinja +++ b/template/[% if repo_platform == 'github' %].github[% endif %]/workflows/devcontainer.yml.jinja @@ -3,6 +3,10 @@ name: DevContainer on: pull_request: + paths: + - .devcontainer/Dockerfile + - .devcontainer/Dockerfile.dockerignore + - .github/workflows/devcontainer.yml push: branches: - main diff --git a/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/devcontainer.yml.jinja b/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/devcontainer.yml.jinja index d3a975b4..3aa29530 100644 --- a/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/devcontainer.yml.jinja +++ b/template/[% if repo_platform == 'gitlab' or repo_platform == 'gitlab-self-managed' %].gitlab[% endif %]/workflows/devcontainer.yml.jinja @@ -26,6 +26,11 @@ dev-container-publish: - .gitlab/workflows/devcontainer.yml if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push" - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "web" + - changes: + - .devcontainer/Dockerfile + - .devcontainer/Dockerfile.dockerignore + - .gitlab/workflows/devcontainer.yml + if: $CI_PIPELINE_SOURCE == 'merge_request_event' script: - docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY} - docker context create builder