chore: manage php dependencies (#6139)
Some checks are pending
Publish Images / Build and Test (push) Waiting to run
Publish Images / Release (push) Blocked by required conditions
Build and Test / Set build metadata (push) Waiting to run
Build and Test / Build and Test (push) Blocked by required conditions
Build and Test / Test the Super-linter GitHub Action (push) Blocked by required conditions
Build and Test / Build test suite matrix (push) Waiting to run
Build and Test / Run test cases (push) Blocked by required conditions
Build and Test / Check if all the tests passed (push) Blocked by required conditions
Build and Test / preview-release-notes (push) Waiting to run
Lint commit / commitlint (push) Waiting to run

- Install PHP dependencies using composer
- Watch composer dependency updates with Dependabot
This commit is contained in:
Marco Ferrari 2024-09-13 08:08:39 +02:00 committed by GitHub
parent 058b9239d4
commit 72a4884f7a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 2313 additions and 67 deletions

View file

@ -68,6 +68,16 @@
"target": "/package-lock.json",
"type": "bind"
},
{
"source": "${localWorkspaceFolder}/dependencies/composer/composer.json",
"target": "/php-composer/composer.json",
"type": "bind"
},
{
"source": "${localWorkspaceFolder}/dependencies/composer/composer.lock",
"target": "/php-composer/composer.lock",
"type": "bind"
},
{
"source": "${localWorkspaceFolder}/scripts/bash-exec.sh",
"target": "/usr/bin/bash-exec",

View file

@ -1,7 +1,4 @@
---
#################################
# GitHub Dependabot Config info #
#################################
version: 2
updates:
- package-ecosystem: "devcontainers"
@ -91,3 +88,12 @@ updates:
schedule:
interval: "weekly"
open-pull-requests-limit: 100
- package-ecosystem: "composer"
commit-message:
prefix: "deps(php)"
directories:
- dependencies/composer
schedule:
interval: "weekly"
open-pull-requests-limit: 100

1
.gitignore vendored
View file

@ -37,6 +37,7 @@ build/Release
# Dependency directories
node_modules/
jspm_packages/
dependencies/composer/vendor
# TypeScript v1 declaration files
typings/

View file

@ -30,6 +30,7 @@ FROM ghcr.io/clj-kondo/clj-kondo:2024.08.01-alpine AS clj-kondo
FROM dart:3.5.1-sdk AS dart
FROM mcr.microsoft.com/dotnet/sdk:8.0.401-alpine3.20 AS dotnet-sdk
FROM mcr.microsoft.com/powershell:7.4-alpine-3.17 AS powershell
FROM composer/composer:2.7.6 AS php-composer
FROM python:3.12.5-alpine3.20 AS clang-format
@ -118,6 +119,13 @@ FROM powershell AS powershell-installer
# when copying PowerShell stuff in the main image
RUN echo "${PS_INSTALL_FOLDER}" > /tmp/PS_INSTALL_FOLDER
FROM php-composer AS php-linters
COPY dependencies/composer/composer.json dependencies/composer/composer.lock /app/
RUN composer update \
&& composer audit
FROM python:3.12.5-alpine3.20 AS base_image
LABEL com.github.actions.name="Super-Linter" \
@ -164,6 +172,8 @@ RUN apk add --no-cache \
php83-curl \
php83-dom \
php83-iconv \
php83-pecl-igbinary \
php83-intl \
php83-mbstring \
php83-openssl \
php83-phar \
@ -230,13 +240,12 @@ WORKDIR /
COPY scripts/install-lua.sh /
RUN --mount=type=secret,id=GITHUB_TOKEN /install-lua.sh && rm -rf /install-lua.sh
##############################
# Install Phive dependencies #
##############################
COPY dependencies/phive.xml /phive.xml
COPY scripts/install-phive.sh /
RUN /install-phive.sh \
&& rm -rfv /install-phive.sh /phive.xml
############################
# Install PHP dependencies #
############################
ENV PHP_COMPOSER_PACKAGES_DIR=/php-composer/vendor
COPY --from=php-composer /usr/bin/composer /usr/bin/
COPY --from=php-linters /app/vendor "${PHP_COMPOSER_PACKAGES_DIR}"
##################
# Install ktlint #
@ -416,6 +425,7 @@ ENV PATH="${PATH}:/venvs/yq/bin"
ENV PATH="${PATH}:/node_modules/.bin"
ENV PATH="${PATH}:/usr/lib/go/bin"
ENV PATH="${PATH}:${DART_SDK}/bin:/root/.pub-cache/bin"
ENV PATH="${PATH}:${PHP_COMPOSER_PACKAGES_DIR}/bin"
# Renovate optionally requires re2, and will warn if its not present
# Setting this envoronment variable disables this warning.

View file

@ -151,6 +151,8 @@ open-shell-super-linter-container: ## Open a shell in the Super-linter container
-v "$(CURDIR)/dependencies/Gemfile":/Gemfile \
-v "$(CURDIR)/dependencies/package-lock.json":/package-lock.json \
-v "$(CURDIR)/dependencies/package.json":/package.json \
-v "$(CURDIR)/dependencies/composer/composer.json":/php-composer/composer.json \
-v "$(CURDIR)/dependencies/composer/composer.lock":/php-composer/composer.lock \
-v "$(CURDIR)/scripts/bash-exec.sh":/usr/bin/bash-exec \
-v "$(CURDIR)/scripts/git-merge-conflict-markers.sh":/usr/bin/git-merge-conflict-markers \
$(SUPER_LINTER_TEST_CONTAINER_URL)

8
dependencies/composer/composer.json vendored Normal file
View file

@ -0,0 +1,8 @@
{
"$schema": "https://getcomposer.org/schema.json",
"require": {
"squizlabs/php_codesniffer": "^3.10.1",
"phpstan/phpstan": "^1.11.2",
"vimeo/psalm": "^5.24.0"
}
}

2238
dependencies/composer/composer.lock generated vendored Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<!-- When adding new linter, do not forget to add its GPG key ID to Dockerfile -->
<phar name="composer" version="^2.7.6" installed="2.7.6" location="./usr/bin/composer" copy="false"/>
<phar name="phpcs" version="^3.10.1" installed="3.10.1" location="/usr/local/bin/phpcs" copy="true"/>
<phar name="phpstan" version="^1.11.2" installed="1.11.2" location="/usr/local/bin/phpstan" copy="true"/>
<phar name="psalm" version="^5.24.0" installed="5.24.0" location="./usr/local/bin/psalm" copy="true"/>
</phive>

View file

@ -1,22 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
apk add --no-cache --virtual .php-build-deps \
gnupg
# Install phive
curl --retry 5 --retry-delay 5 -sLO https://phar.io/releases/phive.phar
curl --retry 5 --retry-delay 5 -sLO https://phar.io/releases/phive.phar.asc
gpg --keyserver hkps://keys.openpgp.org --recv-keys "0x9D8A98B29B2D5D79"
gpg --verify phive.phar.asc phive.phar
chmod +x phive.phar
mv phive.phar /usr/local/bin/phive
rm phive.phar.asc
# Install the PHARs listed in phive.xml
phive --no-progress install \
--trust-gpg-keys 31C7E470E2138192,CF1A108D0E7AE720,8A03EA3B385DBAA1,12CE0F1D262429A5,5E6DDE998AB73B8E,51C67305FFC2E5C0,CBB3D576F2A0946F,689DAD778FF08760E046228BA978220305CD5C32 \
--target /usr/bin
apk del --no-network --purge .php-build-deps

View file

@ -63,6 +63,8 @@ control "super-linter-installed-packages" do
"php83-curl",
"php83-dom",
"php83-iconv",
"php83-pecl-igbinary",
"php83-intl",
"php83-mbstring",
"php83-openssl",
"php83-phar",

View file

@ -290,7 +290,10 @@ COMMAND_TO_RUN+=("${SUPER_LINTER_TEST_CONTAINER_URL}")
declare -i EXPECTED_EXIT_CODE
EXPECTED_EXIT_CODE=${EXPECTED_EXIT_CODE:-0}
# Remove leftovers before instrumenting the test because other tests might have
# created temporary files and caches
RemoveTestLeftovers
RemoveTestLogsAndSuperLinterOutputs
if [[ "${ENABLE_GITHUB_ACTIONS_STEP_SUMMARY}" == "true" ]]; then
debug "Creating GitHub Actions step summary file: ${SUPER_LINTER_GITHUB_STEP_SUMMARY_FILE_PATH}"
@ -307,6 +310,10 @@ SUPER_LINTER_EXIT_CODE=$?
# Enable the errexit option that we check later
set -o errexit
# Remove leftovers after runnint tests because we don't want other tests
# to consider them
RemoveTestLeftovers
debug "Super-linter workspace: ${SUPER_LINTER_WORKSPACE}"
debug "Super-linter exit code: ${SUPER_LINTER_EXIT_CODE}"

View file

@ -192,38 +192,30 @@ RemoveTestLeftovers() {
LEFTOVERS_TO_CLEAN+=("${SUPER_LINTER_WORKSPACE}/${LINTERS_TEST_CASE_DIRECTORY}/rust_clippy/bad/Cargo.lock")
LEFTOVERS_TO_CLEAN+=("${SUPER_LINTER_WORKSPACE}/${LINTERS_TEST_CASE_DIRECTORY}/rust_clippy/good/target")
LEFTOVERS_TO_CLEAN+=("${SUPER_LINTER_WORKSPACE}/${LINTERS_TEST_CASE_DIRECTORY}/rust_clippy/good/Cargo.lock")
LEFTOVERS_TO_CLEAN+=("${SUPER_LINTER_WORKSPACE}/dependencies/composer/vendor")
# Delete leftovers in pwd in case the workspace is not pwd
LEFTOVERS_TO_CLEAN+=("$(pwd)/${LINTERS_TEST_CASE_DIRECTORY}/rust_clippy/bad/target")
LEFTOVERS_TO_CLEAN+=("$(pwd)/${LINTERS_TEST_CASE_DIRECTORY}/rust_clippy/bad/Cargo.lock")
LEFTOVERS_TO_CLEAN+=("$(pwd)/${LINTERS_TEST_CASE_DIRECTORY}/rust_clippy/good/target")
LEFTOVERS_TO_CLEAN+=("$(pwd)/${LINTERS_TEST_CASE_DIRECTORY}/rust_clippy/good/Cargo.lock")
# These variables are defined after configuring test cases, so they might not
# have been initialized yet
if [[ -v LOG_FILE_PATH ]] &&
[[ -n "${LOG_FILE_PATH}" ]]; then
LEFTOVERS_TO_CLEAN+=("${LOG_FILE_PATH}")
LEFTOVERS_TO_CLEAN+=("$(pwd)/$(basename "${LOG_FILE_PATH}")")
fi
if [[ -v SUPER_LINTER_GITHUB_STEP_SUMMARY_FILE_PATH ]] &&
[[ -n "${SUPER_LINTER_GITHUB_STEP_SUMMARY_FILE_PATH}" ]]; then
LEFTOVERS_TO_CLEAN+=("${SUPER_LINTER_GITHUB_STEP_SUMMARY_FILE_PATH}")
LEFTOVERS_TO_CLEAN+=("$(pwd)/$(basename "${SUPER_LINTER_GITHUB_STEP_SUMMARY_FILE_PATH}")")
fi
if [[ -v SUPER_LINTER_MAIN_OUTPUT_PATH ]] &&
[[ -n "${SUPER_LINTER_MAIN_OUTPUT_PATH}" ]]; then
LEFTOVERS_TO_CLEAN+=("${SUPER_LINTER_MAIN_OUTPUT_PATH}")
LEFTOVERS_TO_CLEAN+=("$(pwd)/$(basename "${SUPER_LINTER_MAIN_OUTPUT_PATH}")")
fi
if [[ -v SUPER_LINTER_SUMMARY_FILE_PATH ]] &&
[[ -n "${SUPER_LINTER_SUMMARY_FILE_PATH}" ]]; then
LEFTOVERS_TO_CLEAN+=("${SUPER_LINTER_SUMMARY_FILE_PATH}")
LEFTOVERS_TO_CLEAN+=("$(pwd)/$(basename "${SUPER_LINTER_SUMMARY_FILE_PATH}")")
fi
LEFTOVERS_TO_CLEAN+=("$(pwd)/dependencies/composer/vendor")
debug "Cleaning eventual test leftovers: ${LEFTOVERS_TO_CLEAN[*]}"
sudo rm -rfv "${LEFTOVERS_TO_CLEAN[@]}"
sudo rm -rf "${LEFTOVERS_TO_CLEAN[@]}"
}
RemoveTestLogsAndSuperLinterOutputs() {
local LEFTOVERS_TO_CLEAN=()
LEFTOVERS_TO_CLEAN+=("${LOG_FILE_PATH}")
LEFTOVERS_TO_CLEAN+=("${SUPER_LINTER_GITHUB_STEP_SUMMARY_FILE_PATH}")
LEFTOVERS_TO_CLEAN+=("${SUPER_LINTER_MAIN_OUTPUT_PATH}")
LEFTOVERS_TO_CLEAN+=("${SUPER_LINTER_SUMMARY_FILE_PATH}")
LEFTOVERS_TO_CLEAN+=("$(pwd)/$(basename "${LOG_FILE_PATH}")")
LEFTOVERS_TO_CLEAN+=("$(pwd)/$(basename "${SUPER_LINTER_GITHUB_STEP_SUMMARY_FILE_PATH}")")
LEFTOVERS_TO_CLEAN+=("$(pwd)/$(basename "${SUPER_LINTER_MAIN_OUTPUT_PATH}")")
LEFTOVERS_TO_CLEAN+=("$(pwd)/$(basename "${SUPER_LINTER_SUMMARY_FILE_PATH}")")
debug "Cleaning eventual test logs and Super-linter outputs leftovers: ${LEFTOVERS_TO_CLEAN[*]}"
sudo rm -rf "${LEFTOVERS_TO_CLEAN[@]}"
}