Skip to content

Run tests with service launch #160

Run tests with service launch

Run tests with service launch #160

Workflow file for this run

name: Develop
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-24.04
steps:
- name: checkout
uses: actions/checkout@v4.2.2
- name: Setup JDK
uses: actions/setup-java@v4.6.0
with:
distribution: 'adopt'
java-version: 17
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4.2.2
- name: Build
run: ./gradlew build
- name: Upload build
uses: actions/upload-artifact@v4.5.0
with:
name: release-artifact
path: scripting-host/build/distributions/scripting-host-release.tar.gz
compression-level: '0'
retention-days: 7
test:
runs-on: ubuntu-24.04
needs: [build]
steps:
- name: checkout
uses: actions/checkout@v4.2.2
- name: Setup JDK
uses: actions/setup-java@v4.6.0
with:
distribution: 'adopt'
java-version: 17
- name: Download build
uses: actions/download-artifact@v4.1.8
with:
name: release-artifact
- name: Untar release artifact
run: tar --extract --gunzip --file scripting-host-release.tar.gz
- name: Start nginx
uses: nyurik/action-setup-nginx@v1.1
id: start_ngingx
with:
conf-file-text: |
user runner docker;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 8080;
server_name localhost;
location ~ ^(.*)\.kts(\?.*)?$ {
root html;
try_files \$1.server.kts =404;
include fastcgi_params;
fastcgi_pass unix:$RUNNER_TEMP/kss.sock;
}
}
}
- name: Create test config
run: |
echo "socket.address=$RUNNER_TEMP/kss.sock" >> kss.properties
cp .github/config/logback.xml kss.logback.xml
echo "logging.logback.configurationFile=kss.logback.xml" >> kss.properties
- name: Run tests on nginx
uses: BerniWittmann/background-server-action@v1.1.1
with:
start: ./scripting-host-release/bin/kss
wait-on: sleep 5
command: ./.github/scripts/test.sh "${{ steps.start_ngingx.outputs.html-dir }}"
- name: Test logfile not empty
run: |
if [ ! -f log.txt ]; then
echo "log.txt file doesn't exist"
exit 1
fi
if [ ! -s log.txt ]; then
echo 'log.txt file is empty'
exit 2
fi
- name: Print nginx error logs
if: ${{ failure() }}
run: cat "${{ steps.start_ngingx.outputs.error-log }}"
- name: Print nginx access logs
if: ${{ failure() }}
run: cat "${{ steps.start_ngingx.outputs.access-log }}"
- name: Print kss process logs
if: ${{ failure() }}
run: cat log.txt
test_install_via_script:
strategy:
fail-fast: false
matrix:
runner:
- ubuntu-24.04
- macos-14
runs-on: ${{ matrix.runner }}
needs: build
steps:
- name: checkout
uses: actions/checkout@v4.2.2
- name: Setup JDK
uses: actions/setup-java@v4.6.0
with:
distribution: 'adopt'
java-version: 17
- name: Download build
uses: actions/download-artifact@v4.1.8
with:
name: release-artifact
- name: install latest version
run: sudo --preserve-env ./install.sh --release-fetch-mode archive=scripting-host-release.tar.gz
- name: setup socket
run: |
sudo mkdir -p /var/run/kss/
sudo chmod a+w /var/run/kss/
- name: setup runner config
id: runner_config
run: |
if [[ '${{ matrix.runner }}' == ubuntu* ]]
then
echo 'config_dir=/usr/share/kss/' >> $GITHUB_OUTPUT
echo 'start_cmd=systemctl start kss' >> $GITHUB_OUTPUT
else
echo 'config_dir=/Library/Application Support/kss/' >> $GITHUB_OUTPUT
echo 'start_cmd=launchctl load /Library/LaunchDaemons/kss.plist' >> $GITHUB_OUTPUT
fi
- name: Start kss
run: |
cp .github/config/logback.xml kss.logback.xml
echo "logging.logback.configurationFile=kss.logback.xml" >> kss.properties
sudo mv kss.logback.xml '${{ steps.runner_config.outputs.config_dir }}'
sudo mv kss.properties '${{ steps.runner_config.outputs.config_dir }}'
sudo ${{ steps.runner_config.outputs.start_cmd }}
- name: Start nginx
uses: nyurik/action-setup-nginx@v1.1
id: start_ngingx
with:
conf-file-text: |
user www-data;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 8080;
server_name localhost;
location ~ ^(.*)\.kts(\?.*)?$ {
root html;
try_files \$1.server.kts =404;
include fastcgi_params;
fastcgi_pass unix:/var/run/kss/kss.sock;
}
}
}
- name: run tests
run: ./.github/scripts/test.sh "${{ steps.start_ngingx.outputs.html-dir }}"
- name: Print nginx error logs
if: ${{ failure() }}
run: cat "${{ steps.start_ngingx.outputs.error-log }}"
- name: Print nginx access logs
if: ${{ failure() }}
run: cat "${{ steps.start_ngingx.outputs.access-log }}"
- name: Print kss process logs
if: ${{ failure() }}
run: cat '${{ steps.runner_config.outputs.config_dir }}log.txt'
test_install_script_defaults:
strategy:
matrix:
runner:
- ubuntu-24.04
- macos-14
runs-on: ${{ matrix.runner }}
steps:
- name: checkout
uses: actions/checkout@v4.2.2
- name: Setup JDK
uses: actions/setup-java@v4.6.0
with:
distribution: 'adopt'
java-version: 17
- name: install latest version
run: sudo --preserve-env ./install.sh
env:
GH_TOKEN: ${{ github.token }}
- name: setup socket
run: |
sudo mkdir -p /var/run/kss/
sudo chmod a+w /var/run/kss/
- name: add timeout command to osx
if: ${{ startsWith(matrix.runner, 'macos') }}
run: |
brew install coreutils
sudo ln -s /usr/local/bin/gtimeout /usr/local/bin/timeout
- name: check install
# 124 is cancelled after timeout
run: |
timeout 5s kss || exit_code=$?
if [ "$exit_code" -ne 124 ]
then
echo "expected exit code 124 but was $exit_code"
exit "$exit_code"
fi