mirror of
https://hub.psychoinformatics.de/actions/process-upload.git
synced 2026-10-07 01:16:18 +00:00
93 lines
2.6 KiB
YAML
93 lines
2.6 KiB
YAML
name: Smoke test process-upload action
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
paths:
|
|
- "action.yml"
|
|
- ".github/actions/**"
|
|
- ".github/workflows/smoke-test.yml"
|
|
|
|
jobs:
|
|
smoke-test:
|
|
runs-on: debian-latest
|
|
|
|
steps:
|
|
- name: Checkout action repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Create test uploads
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
rm -rf smoke-test/work
|
|
mkdir -p \
|
|
smoke-test/work/ingest \
|
|
smoke-test/work/orig
|
|
|
|
# Sentinel files must not be treated as uploads.
|
|
touch smoke-test/work/ingest/.gitkeep
|
|
touch smoke-test/work/orig/.gitkeep
|
|
|
|
printf 'id,name\n1,Alice\n' \
|
|
> smoke-test/work/ingest/upload.csv
|
|
|
|
# This is a deliberately simple fixture. The normalizer below
|
|
# converts its comma-separated contents to tab-separated contents.
|
|
printf 'id,name\n1,Alice\n' \
|
|
> smoke-test/work/orig/upload.xlsx
|
|
|
|
- name: Test unmodified-file move
|
|
uses: ./
|
|
with:
|
|
source-dir: smoke-test/work/ingest
|
|
file-pattern: "*.csv"
|
|
target-file: smoke-test/work/data.csv
|
|
commit-and-push: "false"
|
|
|
|
- name: Verify unmodified-file move
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
test -f smoke-test/work/data.csv
|
|
test ! -e smoke-test/work/ingest/upload.csv
|
|
test -f smoke-test/work/ingest/.gitkeep
|
|
|
|
expected=$'id,name\n1,Alice\n'
|
|
actual="$(cat smoke-test/work/data.csv)"
|
|
|
|
if [[ "$actual"$'\n' != "$expected" ]]; then
|
|
echo "Unexpected moved-file contents:" >&2
|
|
cat smoke-test/work/data.csv >&2
|
|
exit 1
|
|
fi
|
|
|
|
- name: Test normalized-file move
|
|
uses: ./
|
|
with:
|
|
source-dir: smoke-test/work/orig
|
|
file-pattern: "*.xlsx"
|
|
target-file: smoke-test/work/data.tsv
|
|
commit-and-push: "false"
|
|
normalizer: |
|
|
tr ',' '\t' < "$INPUT_FILE" > "$OUTPUT_FILE"
|
|
|
|
- name: Verify normalized-file move
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
test -f smoke-test/work/data.tsv
|
|
test ! -e smoke-test/work/orig/upload.xlsx
|
|
test -f smoke-test/work/orig/.gitkeep
|
|
|
|
expected=$'id\tname\n1\tAlice\n'
|
|
actual="$(cat smoke-test/work/data.tsv)"
|
|
|
|
if [[ "$actual"$'\n' != "$expected" ]]; then
|
|
echo "Unexpected normalized-file contents:" >&2
|
|
cat smoke-test/work/data.tsv >&2
|
|
exit 1
|
|
fi
|