Skip to content

wip

wip #1216

Workflow file for this run

# Copyright 2020-2024 Björn Kautler
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This file was generated using Kotlin DSL (.github/workflows/test.main.kts).
# If you want to modify the workflow, please change the Kotlin file and regenerate this YAML file.
# Generated with https://github.com/typesafegithub/github-workflows-kt
name: 'Build and Test'
on:
push: {}
pull_request: {}
schedule:
- cron: '0 0 * * *'
jobs:
check_yaml_consistency:
name: 'Check YAML consistency'
runs-on: 'ubuntu-latest'
steps:
- id: 'step-0'
name: 'Check out'
uses: 'actions/checkout@v4'
- id: 'step-1'
name: 'Execute script'
run: 'rm ''.github/workflows/test.yaml'' && ''.github/workflows/test.main.kts'''
- id: 'step-2'
name: 'Consistency check'
run: 'git diff --exit-code ''.github/workflows/test.yaml'''
build:
name: 'Build'
runs-on: 'windows-latest'
needs:
- 'check_yaml_consistency'
steps:
- id: 'step-0'
name: 'Configure Git'
run: 'git config --global core.autocrlf input'
- id: 'step-1'
name: 'Checkout'
uses: 'actions/checkout@v4'
- id: 'step-2'
name: 'Setup Java 11'
uses: 'actions/setup-java@v4'
with:
java-version: '11'
distribution: 'temurin'
- id: 'step-3'
name: 'Build'
uses: 'burrunan/gradle-cache-action@v1'
with:
debug: 'false'
concurrent: 'true'
arguments: |-
--show-version
build
--info
--stacktrace
--scan
- id: 'step-4'
name: 'Save built artifacts to cache'
uses: 'actions/cache/save@v4'
with:
path: |-
action.yml
build/distributions/
key: '${{ github.run_id }}'
test_default_distribution:
name: 'Test default distribution on ${{ matrix.environment }}'
runs-on: '${{ matrix.environment }}'
needs:
- 'build'
- 'check_yaml_consistency'
strategy:
fail-fast: false
matrix:
environment:
- 'windows-2025'
distribution:
- wsl-id: 'Debian'
user-id: 'Debian'
match-pattern: '*Debian*'
default-absent-tool: 'dos2unix'
steps:
- id: 'step-0'
name: 'Restore built artifacts from cache'
uses: 'actions/cache/restore@v4'
with:
path: |-
action.yml
build/distributions/
key: '${{ github.run_id }}'
fail-on-cache-miss: 'true'
- id: 'step-1'
uses: 'mxschmitt/action-tmate@v3'
- id: 'step-2'
name: 'Execute action'
uses: './'
with:
update: 'true'
wsl-version: '1'
- id: 'step-3'
uses: 'mxschmitt/action-tmate@v3'
if: '${{ always() }}'
- id: 'step-4'
name: 'Test - wsl-bash should be available as custom shell'
shell: 'wsl-bash {0}'
run: ':'
if: |-
always()
&& (steps.step-2.outcome == 'success')
- id: 'step-5'
name: 'Test - wsl-bash should fail if the script fails (provocation)'
continue-on-error: true
shell: 'wsl-bash {0}'
run: 'false'
if: |-
always()
&& (steps.step-2.outcome == 'success')
- id: 'step-6'
name: 'Test - wsl-bash should fail if the script fails (verification)'
shell: 'cmd'
run: 'IF ''${{ steps.step-5.outcome }}'' NEQ ''failure'' EXIT /B 1'
if: |-
always()
&& (steps.step-2.outcome == 'success')
- id: 'step-7'
name: 'Test - wsl-bash should fail if one of the commands fails (provocation)'
continue-on-error: true
shell: 'wsl-bash {0}'
run: |-
false
:
if: |-
always()
&& (steps.step-2.outcome == 'success')
- id: 'step-8'
name: 'Test - wsl-bash should fail if one of the commands fails (verification)'
shell: 'wsl-bash {0}'
run: '[ ''${{ steps.step-7.outcome }}'' == ''failure'' ] || exit 1'
if: |-
always()
&& (steps.step-2.outcome == 'success')
- id: 'step-9'
name: 'Test - wsl-bash should fail if an undefined variable is used (provocation)'
continue-on-error: true
shell: 'wsl-bash {0}'
run: '$foo'
if: |-
always()
&& (steps.step-2.outcome == 'success')
- id: 'step-10'
name: 'Test - wsl-bash should fail if an undefined variable is used (verification)'
shell: 'wsl-bash {0}'
run: '[ ''${{ steps.step-9.outcome }}'' == ''failure'' ]'
if: |-
always()
&& (steps.step-2.outcome == 'success')
- id: 'step-11'
name: 'Test - wsl-bash should fail if any command in a pipe fails (provocation)'
continue-on-error: true
shell: 'wsl-bash {0}'
run: 'false | true'
if: |-
always()
&& (steps.step-2.outcome == 'success')
- id: 'step-12'
name: 'Test - wsl-bash should fail if any command in a pipe fails (verification)'
shell: 'wsl-bash {0}'
run: '[ ''${{ steps.step-11.outcome }}'' == ''failure'' ]'
if: |-
always()
&& (steps.step-2.outcome == 'success')
- id: 'step-13'
name: 'Test - the default distribution should be correct'
shell: 'wsl-bash {0}'
run: |-
cat <(wsl.exe --list || true) <(wsl.exe --list || true | iconv -f UTF-16LE -t UTF-8) <(wslconfig.exe /list || true) <(wslconfig.exe /list || true | iconv -f UTF-16LE -t UTF-8)
[[ "$(cat <(wsl.exe --list || true) <(wsl.exe --list || true | iconv -f UTF-16LE -t UTF-8) <(wslconfig.exe /list || true) <(wslconfig.exe /list || true | iconv -f UTF-16LE -t UTF-8))" == *${{ matrix.distribution.wsl-id }}\ \(Default\)* ]]
if: |-
always()
&& (steps.step-2.outcome == 'success')
- id: 'step-14'
name: 'Test - wsl-bash should use the correct distribution'
shell: 'wsl-bash {0}'
run: |-
cat <(lsb_release -a || true) <(uname -a || true) <([ -d /etc ] && find /etc -maxdepth 1 -type f \( -name '*release' -or -name 'issue*' \) -exec cat {} + || true) <([ -d /etc/products.d ] && find /etc/products.d -maxdepth 1 -type f -name '*.prod' -exec cat {} + || true) <([ -f /proc/version ] && cat /proc/version || true)
[[ "$(cat <(lsb_release -a || true) <(uname -a || true) <([ -d /etc ] && find /etc -maxdepth 1 -type f \( -name '*release' -or -name 'issue*' \) -exec cat {} + || true) <([ -d /etc/products.d ] && find /etc/products.d -maxdepth 1 -type f -name '*.prod' -exec cat {} + || true) <([ -f /proc/version ] && cat /proc/version || true))" == ${{ matrix.distribution.match-pattern }} ]]
if: |-
always()
&& (steps.step-2.outcome == 'success')
- id: 'step-15'
name: 'Test - multi-line commands should not be disturbed by CRLF line endings'
shell: 'wsl-bash {0}'
run: |-
: # this comment catches the CR if present
! grep -q $'\r' "$0" # this comment catches the CR if present
if: |-
always()
&& (steps.step-2.outcome == 'success')
- id: 'step-16'
name: 'Test - wsl-bash should fail if no script file is given (provocation)'
continue-on-error: true
shell: 'wsl-bash'
run: ':'
if: |-
always()
&& (steps.step-2.outcome == 'success')
- id: 'step-17'
name: 'Test - wsl-bash should fail if no script file is given (verification)'
shell: 'wsl-bash {0}'
run: '[ ''${{ steps.step-16.outcome }}'' == ''failure'' ]'
if: |-
always()
&& (steps.step-2.outcome == 'success')
- id: 'step-18'
name: 'Test - wsl-bash should fail if more than one parameter is given and first is not -u (provocation)'
continue-on-error: true
shell: 'wsl-bash user {0}'
run: ':'
if: |-
always()
&& (steps.step-2.outcome == 'success')
- id: 'step-19'
name: 'Test - wsl-bash should fail if more than one parameter is given and first is not -u (verification)'
shell: 'wsl-bash {0}'
run: '[ ''${{ steps.step-18.outcome }}'' == ''failure'' ]'
if: |-
always()
&& (steps.step-2.outcome == 'success')
- id: 'step-20'
name: 'Test - wsl-bash should fail if only user is given (provocation)'
continue-on-error: true
shell: 'wsl-bash -u {0}'
run: ':'
if: |-
always()
&& (steps.step-2.outcome == 'success')
- id: 'step-21'
name: 'Test - wsl-bash should fail if only user is given (verification)'
shell: 'wsl-bash {0}'
run: '[ ''${{ steps.step-20.outcome }}'' == ''failure'' ]'
if: |-
always()
&& (steps.step-2.outcome == 'success')
- id: 'step-22'
name: 'Test - wsl-bash should fail if excess argument is given (provocation)'
continue-on-error: true
shell: 'wsl-bash -u user {0} foo'
run: ':'
if: |-
always()
&& (steps.step-2.outcome == 'success')
- id: 'step-23'
name: 'Test - wsl-bash should fail if excess argument is given (verification)'
shell: 'wsl-bash {0}'
run: '[ ''${{ steps.step-22.outcome }}'' == ''failure'' ]'
if: |-
always()
&& (steps.step-2.outcome == 'success')
- id: 'step-24'
name: 'Test - wsl-bash should fail if given script file does not exist (provocation)'
continue-on-error: true
shell: 'wsl-bash -u user {0}foo'
run: ':'
if: |-
always()
&& (steps.step-2.outcome == 'success')
- id: 'step-25'
name: 'Test - wsl-bash should fail if given script file does not exist (verification)'
shell: 'wsl-bash {0}'
run: '[ ''${{ steps.step-24.outcome }}'' == ''failure'' ]'
if: |-
always()
&& (steps.step-2.outcome == 'success')