This commit is contained in:
Robin Appelman 2025-10-24 01:06:49 +02:00
commit 89fa87e65b
2 changed files with 64 additions and 84 deletions

View file

@ -14,32 +14,26 @@ jobs:
name: PHP-CS-Fixer
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup PHP
uses: https://github.com/shivammathur/setup-php@v2
with:
php-version: '8.0'
extensions: apcu
- name: Composer
run: composer install
- name: PHP-CS-Fixer
uses: https://github.com/OskarStark/php-cs-fixer-ga@2.16.7
with:
args: --diff --dry-run --allow-risky yes --stop-on-violation --using-cache=no --path-mode=intersection
run: |
composer run cs:check
php-versions:
runs-on: ubuntu-22.04
name: Unit tests
name: Unit tests - PHP ${{ matrix.php-version }}
strategy:
fail-fast: false
matrix:
backend:
- smbclient
- libsmbclient
php-version:
- "7.2"
- "7.3"
- "7.4"
- "8.0"
- "8.1"
- "8.2"
- "8.3"
@ -55,9 +49,12 @@ jobs:
steps:
- name: Install packages
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt-get install smbclient libsmbclient-dev
- uses: actions/checkout@v3
sudo apt-get update
sudo apt-get install -y smbclient libsmbclient-dev
- uses: actions/checkout@v4
- name: Setup PHP
uses: https://github.com/shivammathur/setup-php@v2
with:
@ -68,10 +65,8 @@ jobs:
run: composer install
- name: Config
run: |
IP=$(docker inspect ${{ job.services.samba.id }} | jq -r 'map(.NetworkSettings.Networks)[0] | .[].IPAddress')
echo "Samba running at $IP"
echo '{"host": "'$IP'","user": "test","password": "test","share": "test","root": ""}' > tests/config.json
- name: PHPUnit Tests
echo '{"host": "samba","user": "test","password": "test","share": "test","root": ""}' > tests/config.json
- name: PHPUnit Tests - smbclient
uses: https://github.com/nick-invision/retry@v2
with:
timeout_minutes: 2
@ -79,14 +74,23 @@ jobs:
retry_on: timeout
command: php ./vendor/bin/phpunit tests -c tests/phpunit.xml --coverage-clover=coverage.xml
env:
BACKEND: ${{ matrix.backend }}
BACKEND: smbclient
- name: PHPUnit Tests - libsmbclient
uses: https://github.com/nick-invision/retry@v2
with:
timeout_minutes: 2
max_attempts: 3
retry_on: timeout
command: php ./vendor/bin/phpunit tests -c tests/phpunit.xml --coverage-clover=coverage.xml
env:
BACKEND: libsmbclient
- uses: https://github.com/codecov/codecov-action@v3
with:
files: ./coverage.xml
smb-versions:
runs-on: ubuntu-22.04
name: Unit tests
name: Unit tests - Samba ${{ matrix.server-version }} - smbclient ${{ matrix.client-version }}
strategy:
fail-fast: false
@ -116,26 +120,27 @@ jobs:
steps:
- name: Setup smbclient
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt install libjansson4 libcap2 libbsd0 libreadline8 libicu70
sudo apt-get update
sudo apt install -y libjansson4 libcap2 libbsd0 libreadline8 libicu70
sudo mkdir -p /etc/samba /var/lib/samba/private
echo "[global]\nclient min protocol = SMB2\nclient max protocol = SMB3" | sudo tee /etc/samba/smb.conf
sudo wget "https://github.com/icewind1991/smbclient-builder/releases/download/v0.2.0/smbclient-${{ matrix.client-version }}" -O /usr/local/bin/smbclient
sudo chmod +x /usr/local/bin/smbclient
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup PHP
uses: https://github.com/shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.1
extensions: apcu, smbclient
coverage: pcov
- name: Composer
run: composer install
- name: Config
run: |
IP=$(docker inspect ${{ job.services.samba.id }} | jq -r 'map(.NetworkSettings.Networks)[0] | .[].IPAddress')
echo "Samba running at $IP"
echo '{"host": "'$IP'","user": "test","password": "test","share": "test","root": ""}' > tests/config.json
echo '{"host": "samba","user": "test","password": "test","share": "test","root": ""}' > tests/config.json
- name: PHPUnit Tests
uses: https://github.com/nick-invision/retry@v2
with:
@ -150,7 +155,7 @@ jobs:
files: ./coverage.xml
alpine-test:
runs-on: ubuntu-latest
runs-on: alpine-latest
name: Unit tests (alpine)
services:
@ -162,52 +167,25 @@ jobs:
SAMBA_VOLUME_CONFIG_test: "[test]; path=/tmp; valid users = test; guest ok = no; read only = no; browseable = yes"
steps:
- uses: actions/checkout@v3
- name: Setup PHP
uses: https://github.com/shivammathur/setup-php@v2
with:
php-version: 8.0
- uses: actions/checkout@v4
- name: Install dependencies
shell: sh
run: |
apk add bash sudo git coreutils samba-client php composer php-curl php-iconv php-mbstring php-openssl php-zip php-phar php-tokenizer php-dom php-xml php-xmlwriter
- name: Composer
run: composer install
- name: Pull images
run: |
docker pull icewind1991/smbclient-php-alpine
- name: Config
run: |
IP=$(docker inspect ${{ job.services.samba.id }} | jq -r 'map(.NetworkSettings.Networks)[0] | .[].IPAddress')
echo "Samba running at $IP"
echo '{"host": "'$IP'","user": "test","password": "test","share": "test","root": ""}' > tests/config.json
- name: PHPUnit Tests
run: |
docker run --network "host" --rm -v $PWD:/smb icewind1991/smbclient-php-alpine /smb/vendor/bin/phpunit -c /smb/tests/phpunit.xml /smb/tests
kerberos-sso:
runs-on: ubuntu-latest
name: Kerberos SSO tests
steps:
- uses: actions/checkout@v3
- name: Composer
run: composer install
- name: Pull images
run: |
docker pull icewind1991/samba-krb-test-dc
docker pull icewind1991/samba-krb-test-apache
docker pull icewind1991/samba-krb-test-client
- name: Setup AD-DC
run: |
tests/setup-krb.sh
- name: Test kerberos auth
run: |
DC_IP=$(docker inspect dc --format '{{.NetworkSettings.IPAddress}}')
LIST=$(docker run --rm --name client -v /tmp/shared:/shared --dns $DC_IP --hostname client.domain.test icewind1991/samba-krb-test-client \
curl -s --negotiate -u testuser@DOMAIN.TEST: --delegation always http://httpd.domain.test/example-sso-kerberos.php)
echo $LIST
LIST=$(echo $LIST | tr -d '[:space:]')
[[ $LIST == "test.txt" ]]
- name: Apache logs
if: always()
run: |
docker logs apache
echo '{"host": "samba","user": "test","password": "test","share": "test","root": ""}' > tests/config.json
- name: PHPUnit Tests - smbclient
uses: https://github.com/nick-invision/retry@v2
with:
timeout_minutes: 2
max_attempts: 3
retry_on: timeout
command: php ./vendor/bin/phpunit tests -c tests/phpunit.xml --coverage-clover=coverage.xml
env:
BACKEND: smbclient
static-psalm-analysis:
runs-on: ubuntu-latest
@ -217,10 +195,6 @@ jobs:
fail-fast: false
matrix:
php-version:
- "7.2"
- "7.3"
- "7.4"
- "8.0"
- "8.1"
- "8.2"
- "8.3"
@ -228,9 +202,13 @@ jobs:
steps:
- name: krb5-dev
run: sudo apt-get install -y libkrb5-dev libsmbclient-dev
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo apt-get update
sudo apt-get install -y libkrb5-dev libsmbclient-dev
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up php
uses: https://github.com/shivammathur/setup-php@master
with:
@ -251,12 +229,14 @@ jobs:
steps:
- name: krb5-dev
run: sudo apt-get install -y libkrb5-dev
- uses: actions/checkout@v3
run: |
sudo apt-get update
sudo apt-get install -y libkrb5-dev
- uses: actions/checkout@v4
- name: Setup PHP
uses: https://github.com/shivammathur/setup-php@v2
with:
php-version: '8.0'
php-version: 8.3
extensions: apcu, smbclient, krb5
env:
fail-fast: true

View file

@ -24,14 +24,14 @@ function waitContainer {
mkdir /tmp/shared
# start the dc
docker run -dit --name dc -v /tmp/shared:/shared --hostname krb.domain.test --cap-add SYS_ADMIN icewind1991/samba-krb-test-dc
DC_IP=$(docker inspect dc --format '{{.NetworkSettings.IPAddress}}')
docker run -dit --name dc${FORGEJO_RUN_NUMBER} -v /tmp/shared:/shared --hostname krb.domain.test --cap-add SYS_ADMIN icewind1991/samba-krb-test-dc
DC_IP=$(docker inspect dc${FORGEJO_RUN_NUMBER} --format '{{.NetworkSettings.IPAddress}}')
waitContainer dc
waitContainer dc${FORGEJO_RUN_NUMBER}
# start apache
docker run -d --name apache -v $PWD:/var/www/html -v /tmp/shared:/shared --dns $DC_IP --hostname httpd.domain.test icewind1991/samba-krb-test-apache
APACHE_IP=$(docker inspect apache --format '{{.NetworkSettings.IPAddress}}')
docker run -d --name apache${FORGEJO_RUN_NUMBER} -v $PWD:/var/www/html -v /tmp/shared:/shared --dns $DC_IP --hostname httpd.domain.test icewind1991/samba-krb-test-apache
APACHE_IP=$(docker inspect apache${FORGEJO_RUN_NUMBER} --format '{{.NetworkSettings.IPAddress}}')
# add the dns record for apache
docker exec dc samba-tool dns add krb.domain.test domain.test httpd A $APACHE_IP -U administrator --password=passwOrd1
docker exec dc${FORGEJO_RUN_NUMBER} samba-tool dns add krb.domain.test domain.test httpd A $APACHE_IP -U administrator --password=passwOrd1