From 80a1a9b8ebc983dd2103240759a8e6ec942c1541 Mon Sep 17 00:00:00 2001 From: Eddie Kohler Date: Thu, 9 Dec 2021 22:10:39 -0500 Subject: [PATCH] Add GitHub CI. --- .github/workflows/tests.yml | 76 +++++++++++++++++++++++++++++++++++++ .htaccess | 2 +- README.md | 2 +- lib/dbl.php | 6 +-- src/confinvariants.php | 2 +- 5 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 000000000..36e9f86f5 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,76 @@ +name: Tests + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + php-versions: ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0'] + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Start mysql + run: | + (echo '[mysqld]'; echo 'default-authentication-plugin=mysql_native_password') | sudo sh -c "cat > /etc/mysql/conf.d/nativepassword.cnf" + sudo /etc/init.d/mysql start + mysql -V + + - name: Prepare the application + run: | + sudo lib/createdb.sh -u root -proot -c test/options.php --batch + sudo lib/createdb.sh -u root -proot -c test/cdb-options.php --no-dbuser --batch + + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + extensions: mbstring, intl, mysqlnd + + - name: Install poppler + run: sudo apt-get install poppler-utils + + - name: Run tests + run: sh test/check.sh + + build-18: + runs-on: ubuntu-18.04 + + strategy: + matrix: + php-versions: ['7.3', '8.0'] + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Start mysql + run: | + (echo '[mysqld]'; echo 'default-authentication-plugin=mysql_native_password') | sudo sh -c "cat > /etc/mysql/conf.d/nativepassword.cnf" + sudo /etc/init.d/mysql start + mysql -V + + - name: Prepare the application + run: | + sudo lib/createdb.sh -u root -proot -c test/options.php --batch + sudo lib/createdb.sh -u root -proot -c test/cdb-options.php --no-dbuser --batch + + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + extensions: mbstring, intl, mysqlnd + + - name: Install poppler + run: sudo apt-get install poppler-utils + + - name: Run tests + run: sh test/check.sh diff --git a/.htaccess b/.htaccess index bbe167c0c..9f33c645d 100644 --- a/.htaccess +++ b/.htaccess @@ -18,7 +18,7 @@ AddDefaultCharset UTF-8 DirectoryIndex index.php # Prevent access to SCM directory, logs, test, README, regardless of case. -RedirectMatch 403 ^.*/(\.[Gg][Ii][Tt].*|\.[Mm][Yy].*|[Rr][Ee][Aa][Dd][Mm][Ee].*|[Ff][Ii][Ll][Ee][Ss][Tt][Oo][Rr][Ee]|[Dd][Oo][Cc][Ss]|[Cc][Oo][Nn][Ff]|[Cc][Oo][Dd][Ee]|[Ll][Oo][Gg][Ss])($|/.*$) +RedirectMatch 403 ^.*/(\..*|[Rr][Ee][Aa][Dd][Mm][Ee].*|[Ff][Ii][Ll][Ee][Ss][Tt][Oo][Rr][Ee]|[Dd][Oo][Cc][Ss]|[Cc][Oo][Nn][Ff]|[Cc][Oo][Dd][Ee]|[Ll][Oo][Gg][Ss])($|/.*$) # Don't use MultiViews, which can conflict with mod_rewrite suffixless URLs. Options -MultiViews diff --git a/README.md b/README.md index 6436f1a1c..96a2be3e8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -HotCRP Conference Review Software [![Build Status](https://travis-ci.com/kohler/hotcrp.svg?branch=master)](https://travis-ci.com/kohler/hotcrp) +HotCRP Conference Review Software [![Build Status](https://github.com/kohler/hotcrp/actions/workflows/tests.yml/badge.svg)](https://github.com/kohler/hotcrp/actions/workflows/tests.yml) ================================= HotCRP is awesome software for managing review processes, especially for diff --git a/lib/dbl.php b/lib/dbl.php index 922630c9f..f077afa64 100644 --- a/lib/dbl.php +++ b/lib/dbl.php @@ -154,14 +154,14 @@ static function connect_dsn($dsn, $noconnect = false) { global $Opt; $dbhost = $dbuser = $dbpass = $dbname = $dbport = null; - if ($dsn && preg_match('|^mysql://([^:@/]*)/(.*)|', $dsn, $m)) { + if ($dsn && preg_match('/^mysql:\/\/([^:@\/]*)\/(.*)/', $dsn, $m)) { $dbhost = urldecode($m[1]); $dbname = urldecode($m[2]); - } else if ($dsn && preg_match('|^mysql://([^:@/]*)@([^/]*)/(.*)|', $dsn, $m)) { + } else if ($dsn && preg_match('/^mysql:\/\/([^:@\/]*)@([^\/]*)\/(.*)/', $dsn, $m)) { $dbhost = urldecode($m[2]); $dbuser = urldecode($m[1]); $dbname = urldecode($m[3]); - } else if ($dsn && preg_match('|^mysql://([^:@/]*):([^@/]*)@([^/]*)/(.*)|', $dsn, $m)) { + } else if ($dsn && preg_match('/^mysql:\/\/([^:@\/]*):([^@\/]*)@([^\/]*)\/(.*)/', $dsn, $m)) { $dbhost = urldecode($m[3]); $dbuser = urldecode($m[1]); $dbpass = urldecode($m[2]); diff --git a/src/confinvariants.php b/src/confinvariants.php index e5d4d9450..c95e68308 100644 --- a/src/confinvariants.php +++ b/src/confinvariants.php @@ -163,7 +163,7 @@ function exec_main() { // whitespace is simplified $regex = Dbl::utf8($this->conf->dblink, "'^ | \$| |[\\n\\r\\t]'"); - $any = $this->invariantq("select email from ContactInfo where firstName regexp $regex or lastName regexp $regex or affiliation regexp $regex limit 1"); + $any = $this->invariantq("select email from ContactInfo where convert(firstName using utf8mb4) regexp $regex or convert(lastName using utf8mb4) regexp $regex or convert(affiliation using utf8mb4) regexp $regex limit 1"); if ($any) { $this->invariant_error("user_whitespace", "user whitespace is not simplified"); }