mirror of
https://github.com/eth-p/bat-extras.git
synced 2025-06-20 11:47:43 +02:00
ci: Add GitHub Actions test workflow
This will eventually replace CircleCI.
This commit is contained in:
parent
ad2d788d6c
commit
90bb604d74
54
.github/actions/build/action.yaml
vendored
Normal file
54
.github/actions/build/action.yaml
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
name: 'Build'
|
||||
description: 'Builds bat-extras'
|
||||
inputs:
|
||||
manuals:
|
||||
description: 'Builds manuals'
|
||||
required: false
|
||||
default: true
|
||||
inline:
|
||||
description: 'Inlines executable names in script'
|
||||
required: false
|
||||
default: true
|
||||
verify:
|
||||
description: 'Verifies after building'
|
||||
required: false
|
||||
default: false
|
||||
minify:
|
||||
description: 'Minification mode (none, all, lib)'
|
||||
required: false
|
||||
default: 'none'
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
|
||||
- name: Run build script
|
||||
shell: bash
|
||||
run: |
|
||||
args=(
|
||||
--banner
|
||||
--minify="${{ inputs.minify }}"
|
||||
)
|
||||
|
||||
if "${{ inputs.manuals }}"; then
|
||||
args+=(--manuals)
|
||||
else
|
||||
args+=(--no-manuals)
|
||||
fi
|
||||
|
||||
if "${{ inputs.verify }}"; then
|
||||
args+=(--verify)
|
||||
else
|
||||
args+=(--no-verify)
|
||||
fi
|
||||
|
||||
if "${{ inputs.inline }}"; then
|
||||
args+=(--inline)
|
||||
else
|
||||
args+=(--no-inline)
|
||||
fi
|
||||
|
||||
# Run the build script.
|
||||
cd "${{ github.workspace }}"
|
||||
PATH="${{ runner.temp }}/bin:${PATH}"
|
||||
bash "${{ github.workspace }}/build.sh" "${args[@]}"
|
87
.github/actions/install-dependencies/action.yaml
vendored
Normal file
87
.github/actions/install-dependencies/action.yaml
vendored
Normal file
@ -0,0 +1,87 @@
|
||||
name: 'Install dependencies'
|
||||
description: 'Installs all the dependencies needed.'
|
||||
inputs:
|
||||
build:
|
||||
description: 'Install build dependencies.'
|
||||
required: false
|
||||
default: true
|
||||
test:
|
||||
description: 'Install test dependencies.'
|
||||
required: true
|
||||
default: false
|
||||
|
||||
version_bat:
|
||||
description: 'The version of bat to install.'
|
||||
required: false
|
||||
default: "latest"
|
||||
|
||||
version_ripgrep:
|
||||
description: 'The version of ripgrep to install.'
|
||||
required: false
|
||||
default: "latest"
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
|
||||
- name: Create directories
|
||||
shell: bash
|
||||
run: |
|
||||
test -d "${RUNNER_TEMP}/bin" || mkdir -p "${RUNNER_TEMP}/bin"
|
||||
test -d "${RUNNER_TEMP}/dl" || mkdir -p "${RUNNER_TEMP}/dl"
|
||||
|
||||
- name: Install shfmt (build dependency)
|
||||
shell: bash
|
||||
if: ${{ env.ACT || inputs.build == 'true' }}
|
||||
run: |
|
||||
curl \
|
||||
--silent \
|
||||
--location \
|
||||
--output "${RUNNER_TEMP}/bin/shfmt" \
|
||||
"https://github.com/patrickvane/shfmt/releases/download/master/shfmt_linux_amd64"
|
||||
chmod +x "${RUNNER_TEMP}/bin/shfmt"
|
||||
|
||||
- name: Download bat (test dependency)
|
||||
uses: dsaltares/fetch-gh-release-asset@1.0.0
|
||||
if: ${{ env.ACT || inputs.test == 'true' }}
|
||||
with:
|
||||
file: "bat-v[0-9\\.]+-x86_64-unknown-linux-gnu.tar.gz"
|
||||
repo: "sharkdp/bat"
|
||||
# version: "${{ inputs.version_bat || "latest" }}"
|
||||
regex: true
|
||||
target: ".dl/"
|
||||
|
||||
- name: Install bat
|
||||
shell: bash
|
||||
if: ${{ env.ACT || inputs.test == 'true' }}
|
||||
run: |
|
||||
tar -xf \
|
||||
"${{ github.workspace }}/.dl"/bat-*.tar.* \
|
||||
-C "${{ runner.temp }}/dl/"
|
||||
|
||||
find "${{ runner.temp }}/dl" \
|
||||
-type f -iname "bat" \
|
||||
-exec mv {} "${RUNNER_TEMP}/bin/" \;
|
||||
|
||||
- name: Download ripgrep (test dependency)
|
||||
uses: dsaltares/fetch-gh-release-asset@1.0.0
|
||||
if: ${{ env.ACT || inputs.test == 'true' }}
|
||||
with:
|
||||
file: "ripgrep_[0-9\\.]+_amd64.deb"
|
||||
repo: "BurntSushi/ripgrep"
|
||||
# version: "${{ inputs.version_ripgrep || "latest" }}"
|
||||
regex: true
|
||||
target: ".dl/"
|
||||
|
||||
- name: Install ripgrep
|
||||
shell: bash
|
||||
if: ${{ env.ACT || inputs.test == 'true' }}
|
||||
run: |
|
||||
dpkg-deb -x \
|
||||
"${{ github.workspace }}/.dl"/ripgrep_*.deb \
|
||||
"${{ runner.temp }}/dl/"
|
||||
|
||||
find "${{ runner.temp }}/dl" \
|
||||
-type f -iname "rg" \
|
||||
-exec mv {} "${{ runner.temp }}/bin/" \;
|
||||
|
33
.github/actions/test/action.yaml
vendored
Normal file
33
.github/actions/test/action.yaml
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
name: 'Test'
|
||||
description: 'Tests bat-extras'
|
||||
inputs:
|
||||
strict:
|
||||
description: 'Tests should be run under strict mode'
|
||||
required: false
|
||||
default: false
|
||||
compiled:
|
||||
description: 'Test scripts that have been built'
|
||||
required: false
|
||||
default: false
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
|
||||
- name: Run tests
|
||||
shell: bash
|
||||
run: |
|
||||
args=()
|
||||
|
||||
if "${{ inputs.compiled }}"; then
|
||||
args+=(--compiled)
|
||||
fi
|
||||
|
||||
if "${{ inputs.strict }}"; then
|
||||
args+=(--strict)
|
||||
fi
|
||||
|
||||
cd "${{ github.workspace }}"
|
||||
PATH="${{ runner.temp }}/bin:${PATH}"
|
||||
bash "${{ github.workspace }}/test.sh" "${args[@]}" \
|
||||
--verbose --snapshot:show
|
96
.github/workflows/test.yaml
vendored
Normal file
96
.github/workflows/test.yaml
vendored
Normal file
@ -0,0 +1,96 @@
|
||||
name: Test
|
||||
on:
|
||||
push: {}
|
||||
pull_request:
|
||||
types: [opened, synchronize]
|
||||
|
||||
jobs:
|
||||
"Build":
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out sources
|
||||
uses: actions/checkout@v3
|
||||
- name: Install build dependencies
|
||||
uses: ./.github/actions/install-dependencies
|
||||
with:
|
||||
build: true
|
||||
test: false
|
||||
- name: Build artifacts
|
||||
uses: ./.github/actions/build
|
||||
with:
|
||||
minify: lib
|
||||
manuals: true
|
||||
verify: false
|
||||
inline: false
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
if: ${{ !env.ACT && !failure() }}
|
||||
with:
|
||||
path: |
|
||||
${{ github.workspace }}/bin/
|
||||
${{ github.workspace }}/doc/
|
||||
|
||||
"Test":
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out sources
|
||||
uses: actions/checkout@v3
|
||||
- name: Install test dependencies
|
||||
uses: ./.github/actions/install-dependencies
|
||||
with:
|
||||
build: false
|
||||
test: true
|
||||
- name: Test scripts
|
||||
uses: ./.github/actions/test
|
||||
|
||||
"Test_Consistency":
|
||||
runs-on: ubuntu-latest
|
||||
needs: "Test"
|
||||
steps:
|
||||
- name: Check out sources
|
||||
uses: actions/checkout@v3
|
||||
- name: Install dependencies
|
||||
uses: ./.github/actions/install-dependencies
|
||||
with:
|
||||
build: true
|
||||
test: true
|
||||
- name: Build scripts
|
||||
uses: ./.github/actions/build
|
||||
with:
|
||||
minify: lib
|
||||
manuals: false
|
||||
verify: false
|
||||
inline: false
|
||||
- name: Test built scripts
|
||||
uses: ./.github/actions/test
|
||||
with:
|
||||
compiled: true
|
||||
|
||||
"Test_Symlinks":
|
||||
runs-on: ubuntu-latest
|
||||
needs: "Test"
|
||||
env:
|
||||
BAT_PAGER: 'cat'
|
||||
steps:
|
||||
- name: Check out sources
|
||||
uses: actions/checkout@v3
|
||||
- name: Install dependencies
|
||||
uses: ./.github/actions/install-dependencies
|
||||
with:
|
||||
build: false
|
||||
test: true
|
||||
- name: Prepare symlinks
|
||||
run: |
|
||||
chmod +x "${{ github.workspace }}/src/batgrep.sh"
|
||||
ln -s "${{ github.workspace }}/src/batgrep.sh" "${{ runner.temp }}/absolute-batgrep"
|
||||
(cd "${{ github.workspace }}" && ln -s "src/batgrep.sh" relative-batgrep)
|
||||
- name: Test absolute symlink
|
||||
run: |
|
||||
PATH="${{ runner.temp }}/bin:${PATH}"
|
||||
"${{ runner.temp }}/absolute-batgrep" 'a' <<< 'abc'
|
||||
- name: Test relative symlink
|
||||
run: |
|
||||
PATH="${{ runner.temp }}/bin:${PATH}"
|
||||
"${{ github.workspace }}/relative-batgrep" 'a' <<< 'abc'
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user