mikuli.cz

:)
git clone https://git.sr.ht/~ashymad/mikuli.cz
Log | Files | Refs

commit 1508888567ba7dfd37bf1c56b61973e082348b2c
parent edcef7ebf66562bcd0eff5812788269076166a8e
Author: markseu <mark2011@mayberg.se>
Date:   Mon, 20 Nov 2023 21:36:57 +0100

Updated system tests

Diffstat:
A.github/workflows/make-tests.php | 62++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A.github/workflows/system-tests.yml | 69+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
D.github/workflows/tests.yml | 28----------------------------
3 files changed, 131 insertions(+), 28 deletions(-)

diff --git a/.github/workflows/make-tests.php b/.github/workflows/make-tests.php @@ -0,0 +1,62 @@ +<?php +// Datenstrom Yellow, https://github.com/datenstrom/yellow + +if (PHP_SAPI!="cli") { + echo "ERROR making test environment: Please run at the command line!\n"; +} else { + if (!is_dir("tests")) { + echo "Making test environment...\n"; + $extensions = $errors = 0; + mkdir("tests/system/extensions", 0777, true); + copy("yellow.php", "tests/yellow.php"); + copy("system/extensions/core.php", "tests/system/extensions/core.php"); + copy("system/extensions/update.php", "tests/system/extensions/update.php"); + $fileData = date("Y-m-d H:i:s")." info Make test environment for Datenstrom Yellow\n"; + file_put_contents("tests/system/extensions/yellow-website.log", $fileData); + $fileData = "# Datenstrom Yellow system settings\n\nUpdateCurrentRelease: latest\nGenerateStaticUrl: http://localhost:8000/"; + file_put_contents("tests/system/extensions/yellow-system.ini", $fileData); + $fileData = file_get_contents("system/extensions/update-latest.ini"); + $curlHandle = curl_init(); + preg_match_all("/DownloadUrl\s*:\s*(.*?)\s*[\r\n]+/i", $fileData, $urls); + foreach ($urls[1] as $url) { + $downloadUrl = $url; + if (preg_match("#^https://github.com/annaesvensson/yellow-core/#", $url)) { + ++$extensions; continue; + } + if (preg_match("#^https://github.com/annaesvensson/yellow-update/#", $url)) { + ++$extensions; continue; + } + if (preg_match("#^https://github.com/(.+)/archive/refs/heads/main.zip$#", $url, $matches)) { + $downloadUrl = "https://codeload.github.com/".$matches[1]."/zip/refs/heads/main"; + } + if (preg_match("#^https://github.com/(.+)/raw/main/(.+)$#", $url, $matches)) { + $downloadUrl = "https://raw.githubusercontent.com/".$matches[1]."/main/".$matches[2]; + } + curl_setopt($curlHandle, CURLOPT_URL, $downloadUrl); + curl_setopt($curlHandle, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; MakeTests/0.8.1; SoftwareTester)"); + curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curlHandle, CURLOPT_CONNECTTIMEOUT, 30); + $rawData = curl_exec($curlHandle); + $statusCode = curl_getinfo($curlHandle, CURLINFO_HTTP_CODE); + if ($statusCode==200) { + ++$extensions; + $fileName = "tests/system/extensions/download-$extensions.zip"; + file_put_contents($fileName, $rawData); + } else { + ++$errors; + echo "ERROR downloading $url, status $statusCode!\n"; + } + } + curl_close($curlHandle); + exec("cd tests; php yellow.php update; php yellow.php update", $outputLines, $returnStatus); + if ($returnStatus!=0) { + ++$errors; + foreach ($outputLines as $line) echo "$line\n"; + } + file_put_contents("tests/content/contact/page.md", "exclude\n"); //TODO: remove later, exclude contact page for now + file_put_contents("tests/content/search/page.md", "exclude\n"); //TODO: remove later, exclude search page for now + echo "Test environment: $extensions extension".($extensions!=1 ? "s" : ""); + echo ", $errors error".($errors!=1 ? "s" : "")."\n"; + exit($errors==0 ? 0 : 1); + } +} diff --git a/.github/workflows/system-tests.yml b/.github/workflows/system-tests.yml @@ -0,0 +1,69 @@ +# Datenstrom Yellow system tests + +name: System tests +on: [push, pull_request] +jobs: + installation-tests: + name: Installation on ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} + steps: + - name: Check out code + uses: actions/checkout@v3 + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: latest + extensions: curl, gd, mbstring, zip + ini-file: development + coverage: none + tools: none + - name: Set up problem matcher + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" + - name: Set up test environment + run: php yellow.php skip installation + php-tests: + name: PHP ${{ matrix.php }} + strategy: + matrix: + php: [8.2, 8.1, 8.0, 7.4, 7.3, 7.2, 7.1, 7.0] + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v3 + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: curl, gd, mbstring, zip + ini-file: development + coverage: none + tools: none + - name: Set up problem matcher + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" + - name: Set up test environment + run: php yellow.php skip installation + - name: Run tests + run: php yellow.php generate tests + extension-tests: + name: Extensions + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v3 + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: latest + extensions: curl, gd, mbstring, zip + ini-file: development + coverage: none + tools: none + - name: Set up problem matcher + run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" + - name: Set up test environment + run: php .github/workflows/make-tests.php + - name: Run tests + run: cd tests; php yellow.php generate tests diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml @@ -1,28 +0,0 @@ -# Datenstrom Yellow system tests - -name: System tests -on: [push, pull_request] -jobs: - tests: - name: PHP ${{ matrix.php }} - strategy: - matrix: - php: [8.2, 8.1, 8.0, 7.4, 7.3, 7.2, 7.1, 7.0] - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@v3 - - name: Set up PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: curl, gd, mbstring, zip - ini-file: development - coverage: none - tools: none - - name: Set up problem matcher - run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" - - name: Set up test environment - run: php yellow.php skip installation - - name: Run tests - run: php yellow.php generate tests