Add option to install specific version #203
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Develop | |
on: | |
workflow_dispatch: | |
pull_request: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: checkout | |
uses: actions/[email protected] | |
- name: Setup JDK | |
uses: actions/[email protected] | |
with: | |
distribution: 'temurin' | |
java-version: 17 | |
- name: Setup Gradle | |
uses: gradle/actions/[email protected] | |
- name: Build | |
run: | | |
./gradlew build | |
mv scripting-host/build/distributions/scripting-host-release*.tar.gz scripting-host-release.tar.gz | |
- name: Upload build | |
uses: actions/[email protected] | |
with: | |
name: release-artifact | |
path: scripting-host-release.tar.gz | |
compression-level: '0' | |
retention-days: 7 | |
test: | |
runs-on: ubuntu-24.04 | |
needs: [build] | |
steps: | |
- name: checkout | |
uses: actions/[email protected] | |
- name: Setup JDK | |
uses: actions/[email protected] | |
with: | |
distribution: 'temurin' | |
java-version: 17 | |
- name: Download build | |
uses: actions/[email protected] | |
with: | |
name: release-artifact | |
- name: Untar release artifact | |
run: | | |
mkdir scripting-host-release | |
tar --extract --gunzip --directory scripting-host-release --strip-components 1 --file scripting-host-release.tar.gz | |
- name: Test version output | |
timeout-minutes: 1 | |
run: | | |
version="$(cat gradle.properties | sed -n 's/version=//p')" | |
hostVersion=$(./scripting-host-release/bin/kss --version) | |
if [ "$hostVersion" != "Version: $version" ]; then | |
echo "host version ($hostVersion) doesn't match gradle properties version ($version)" | |
exit 1 | |
fi | |
- name: Start nginx | |
uses: nyurik/[email protected] | |
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/[email protected] | |
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_service: | |
strategy: | |
fail-fast: false | |
matrix: | |
runner: | |
- ubuntu-24.04 | |
- macos-14 | |
runs-on: ${{ matrix.runner }} | |
needs: build | |
steps: | |
- name: checkout | |
uses: actions/[email protected] | |
- name: Setup JDK | |
uses: actions/[email protected] | |
with: | |
distribution: 'temurin' | |
java-version: 17 | |
# HOME directory needs to be accessible by _www, so the java executable can be used | |
# not needed for linux, because JDK is not put in user directory | |
- name: Set launchd path | |
if: ${{ startsWith(matrix.runner, 'macos') }} | |
run: | | |
chmod o+rx "$HOME" | |
sudo launchctl setenv JAVA_HOME "$JAVA_HOME" | |
- name: Download build | |
uses: actions/[email protected] | |
with: | |
name: release-artifact | |
- name: install latest version | |
run: sudo ./install.sh --release-fetch-mode archive=scripting-host-release.tar.gz | |
- 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 | |
echo 'user=www-data' >> $GITHUB_OUTPUT | |
else | |
echo 'config_dir=/Library/Application Support/kss/' >> $GITHUB_OUTPUT | |
echo 'start_cmd=launchctl load -w /Library/LaunchDaemons/kss.plist' >> $GITHUB_OUTPUT | |
echo 'user=_www' >> $GITHUB_OUTPUT | |
fi | |
- name: setup socket | |
run: | | |
sudo mkdir -p /var/run/kss/ | |
sudo chown '${{ steps.runner_config.outputs.user }}' /var/run/kss/ | |
- name: Start kss | |
run: | | |
sudo cp .github/config/logback.xml '${{ steps.runner_config.outputs.config_dir }}kss.logback.xml' | |
echo "logging.logback.configurationFile=${{ steps.runner_config.outputs.config_dir }}kss.logback.xml" >> kss.properties | |
echo "dependencies.maven.homeDirectory=${{ steps.runner_config.outputs.config_dir }}.m2" >> kss.properties | |
sudo chown '${{ steps.runner_config.outputs.user }}' '${{ steps.runner_config.outputs.config_dir }}' | |
sudo mkdir '${{ steps.runner_config.outputs.config_dir }}.m2' | |
sudo chown '${{ steps.runner_config.outputs.user }}' '${{ steps.runner_config.outputs.config_dir }}.m2' | |
sudo mv kss.properties '${{ steps.runner_config.outputs.config_dir }}' | |
sudo ${{ steps.runner_config.outputs.start_cmd }} | |
- name: Start nginx | |
uses: nyurik/[email protected] | |
id: start_ngingx | |
with: | |
conf-file-text: | | |
user ${{ steps.runner_config.outputs.user }}; | |
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' | |
- name: Print macos kss process logs | |
if: ${{ failure() && startsWith(matrix.runner, 'macos') }} | |
run: | | |
if [ -f '/Library/Logs/kss.log' ] | |
then | |
cat '/Library/Logs/kss.log' | |
fi | |
- name: Print macos kss error logs | |
if: ${{ failure() && startsWith(matrix.runner, 'macos') }} | |
run: | | |
if [ -f '/Library/Logs/kss-error.log' ] | |
then | |
cat '/Library/Logs/kss-error.log' | |
fi |