Skip to content

fix: postgresql compatibility #33

fix: postgresql compatibility

fix: postgresql compatibility #33

Workflow file for this run

name: CI
on:
push:
branches: [ '**' ]
paths-ignore:
- '**.md'
pull_request:
branches: [ master, release-* ]
paths-ignore:
- '**.md'
jobs:
basic-tests:
name: Syntax and unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-latest]
php-versions: ['7.4', '8.0']
steps:
- name: Setup test MySQL database
run: |
sudo systemctl start mysql.service
mysql -uroot -proot -e 'CREATE DATABASE IF NOT EXISTS simplesamlphp;'
mysql -uroot -proot -e '
CREATE TABLE IF NOT EXISTS `AttributeFromSQL` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`uid` VARCHAR(100) NOT NULL,
`sp` VARCHAR(250) DEFAULT "%",
`attribute` VARCHAR(30) NOT NULL,
`value` TEXT,
`expires` DATE DEFAULT "9999-12-31",
PRIMARY KEY (`id`)
) DEFAULT CHARSET=utf8;
CREATE USER IF NOT EXISTS `phpunit`@`localhost` IDENTIFIED BY "phpunit";
GRANT ALL ON `simplesamlphp`.* TO `phpunit`@`localhost`;
' simplesamlphp
mysql -uroot -proot -e "
INSERT INTO AttributeFromSQL (uid, sp, attribute, value) VALUES ('user@example.org', '%', 'eduPersonEntitlement', 'urn:mace:exampleIdP.org:demoservice:demo-admin');
INSERT INTO AttributeFromSQL (uid, sp, attribute, value) VALUES ('user@example.org', 'https://idp.example.org/idp/shibboleth', 'eduPersonEntitlement', 'urn:mace:grnet.gr:eduroam:admin');
INSERT INTO AttributeFromSQL (uid, sp, attribute, value) VALUES ('user@example.org', '%', 'eduPersonAffiliation', 'faculty');
INSERT INTO AttributeFromSQL (uid, attribute, value) VALUES ('user@example.org', 'mail', 'user@example.org');
INSERT INTO AttributeFromSQL (uid, attribute, value, expires) VALUES ('user@example.org', 'mail', 'marty@example.org', '2015-10-21');
" simplesamlphp
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
coverage: pcov
extensions: intl, mbstring, xml
ini-values: error_reporting=E_ALL
php-version: ${{ matrix.php-versions }}
tools: composer:v2
- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- uses: actions/checkout@v3
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Validate composer.json and composer.lock
run: composer validate
- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader
- name: Syntax check PHP
run: bash vendor/bin/check-syntax-php.sh
- name: Decide whether to run code coverage or not
if: ${{ matrix.php-versions != '7.4' || matrix.operating-system != 'ubuntu-latest' }}
run: |
echo "NO_COVERAGE=--no-coverage" >> $GITHUB_ENV
- name: Run unit tests
run: |
echo $NO_COVERAGE
./vendor/bin/phpunit $NO_COVERAGE
- name: Save coverage data
if: ${{ matrix.php-versions == '7.4' && matrix.operating-system == 'ubuntu-latest' }}
uses: actions/upload-artifact@v3
with:
name: build-data
path: ${{ github.workspace }}/build
security:
name: Security checks
runs-on: [ubuntu-latest]
steps:
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: '7.4'
extensions: mbstring, xml
tools: composer:v2
coverage: none
- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- uses: actions/checkout@v3
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader
- name: Security check for locked dependencies
uses: symfonycorp/security-checker-action@v3
- name: Update Composer dependencies
run: composer update --no-progress --prefer-dist --optimize-autoloader
- name: Security check for updated dependencies
uses: symfonycorp/security-checker-action@v3
sanity-check:
name: Sanity checks
runs-on: [ubuntu-latest]
steps:
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: '7.4'
extensions: mbstring, xml
tools: composer:v2
coverage: none
- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- uses: actions/checkout@v3
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader
- name: Syntax check YAML / XML / JSON
run: |
bash vendor/bin/check-syntax-yaml.sh
bash vendor/bin/check-syntax-xml.sh
bash vendor/bin/check-syntax-json.sh
quality:
name: Quality control
runs-on: [ubuntu-latest]
needs: [basic-tests]
steps:
- name: Setup PHP, with composer and extensions
id: setup-php
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: '7.4'
tools: composer:v2
extensions: mbstring, xml
- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- uses: actions/checkout@v3
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader
- uses: actions/download-artifact@v3
with:
name: build-data
path: ${{ github.workspace }}/build
- name: Codecov
uses: codecov/codecov-action@v3
- name: PHP Code Sniffer
continue-on-error: true
run: php vendor/bin/phpcs
- name: Psalm
continue-on-error: true
run: php vendor/bin/psalm --show-info=true --shepherd --php-version=${{ steps.setup-php.outputs.php-version }}
- name: Psalter
continue-on-error: true
run: php vendor/bin/psalter --issues=UnnecessaryVarAnnotation --dry-run --php-version=${{ steps.setup-php.outputs.php-version }}