From ff07d6d5cca5fe051c1f40e27ee7e7eec49999a7 Mon Sep 17 00:00:00 2001 From: Marius Ghita Date: Wed, 8 Jan 2025 17:27:29 +0200 Subject: [PATCH 1/3] feat: local env vars for private packagist #0000 Provide a way to be able to overwrite private packagist login credentials when devcontainer is used locally, and not in CodeSpaces. --- templates/.devcontainer/devcontainer.json.j2 | 6 ++++++ templates/.devcontainer/postCreate.sh.j2 | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/templates/.devcontainer/devcontainer.json.j2 b/templates/.devcontainer/devcontainer.json.j2 index e2b49a2..c047727 100644 --- a/templates/.devcontainer/devcontainer.json.j2 +++ b/templates/.devcontainer/devcontainer.json.j2 @@ -29,6 +29,12 @@ "description": "Packagist access token, required for installation of composer packages from private packagist", "documentationUrl": "https://packagist.com/orgs/linkorb" } +{% endif %} + }, + "remoteEnv": { +{% if repo.devcontainer.private_packagist and (repo.type in ['application', 'library', 'symfony-bundle'] or repo.type.startswith('php-')) %} + "GITHUB_USER_ON_HOST": "${localEnv:GITHUB_USER}", + "PACKAGIST_TOKEN_ON_HOST": "${localEnv:PACKAGIST_TOKEN}" {% endif %} }, "postCreateCommand": ".devcontainer/postCreate.sh", diff --git a/templates/.devcontainer/postCreate.sh.j2 b/templates/.devcontainer/postCreate.sh.j2 index b265f15..d9d971e 100755 --- a/templates/.devcontainer/postCreate.sh.j2 +++ b/templates/.devcontainer/postCreate.sh.j2 @@ -14,7 +14,8 @@ git config commit.template .devcontainer/git/linkorb_commit.template {% if repo.type in ['application', 'library', 'symfony-bundle'] or repo.type.startswith('php-') %} {% if repo.devcontainer.private_packagist %} -composer config --global --auth http-basic.repo.packagist.com "$GITHUB_USER" "$PACKAGIST_TOKEN" +composer config --global --auth http-basic.repo.packagist.com \ + "${GITHUB_USER:-$GITHUB_USER_ON_HOST}" "${PACKAGIST_TOKEN:-$PACKAGIST_TOKEN_ON_HOST}" {% endif %} composer install From 7b8b7f5676344419febbc2c5b14b240672d618bd Mon Sep 17 00:00:00 2001 From: Marius Ghita Date: Wed, 8 Jan 2025 17:29:32 +0200 Subject: [PATCH 2/3] chore: remove python3 specific step #0000 The step was necessary in devcontainers because repo-ansible requires python dependencies to run. Since repo-ansible provides docker containers instead for common usage the python+debian workaround is no longer necessary. --- templates/.devcontainer/postCreate.sh.j2 | 4 ---- 1 file changed, 4 deletions(-) diff --git a/templates/.devcontainer/postCreate.sh.j2 b/templates/.devcontainer/postCreate.sh.j2 index d9d971e..33ac012 100755 --- a/templates/.devcontainer/postCreate.sh.j2 +++ b/templates/.devcontainer/postCreate.sh.j2 @@ -1,10 +1,6 @@ #!/usr/bin/env bash # {{ repo_managed }} -# Workaround for recent Python versions which prevent global pip package installation without an explicit flag -# or removal of a certain file. -sudo rm /usr/lib/python3.*/EXTERNALLY-MANAGED || true - # This is a workaround on an issue with the devcontainer reported on Windows where followup git config commands would # fail. #9067 git config --global --add safe.directory /app From 0c585320e8ffa1591ad51ad70c2fea6dd6926e60 Mon Sep 17 00:00:00 2001 From: Marius Ghita Date: Wed, 8 Jan 2025 17:34:23 +0200 Subject: [PATCH 3/3] chore: remove composer-unused hook removal #0000 This was a temporary workaround fix, to remove composer-unused for repo-ansible managed projects that already had it enabled. Most of those should no longer have composer-unused hook present at this point in time. --- templates/.devcontainer/postStart.sh.j2 | 7 ------- 1 file changed, 7 deletions(-) diff --git a/templates/.devcontainer/postStart.sh.j2 b/templates/.devcontainer/postStart.sh.j2 index 7f2591f..98e2409 100755 --- a/templates/.devcontainer/postStart.sh.j2 +++ b/templates/.devcontainer/postStart.sh.j2 @@ -1,11 +1,4 @@ #!/usr/bin/env bash # {{ repo_managed }} -# pre-push composer-unused hook disabled. See Card #8980 -if [ -f .git/hooks/pre-push ]; then - diff .devcontainer/git/hooks/pre-push .git/hooks/pre-push - if [ $? -eq 0 ]; then - rm .git/hooks/pre-push - fi -fi {{ repo.devcontainer.postStartCommand|default('') }}