Skip to content

Convert Storybooks #190

Convert Storybooks

Convert Storybooks #190

Workflow file for this run

name: PWA Lint & Test
on:
push:
branches: ['*']
pull_request:
branches: ['*']
jobs:
setup:
runs-on: ubuntu-latest
outputs:
appbuilder_version: ${{ steps.get_version.outputs.appbuilder_version }}
steps:
- uses: actions/checkout@v4
- uses: volta-cli/action@v4
- name: Get environment info
run: |
node --version
npm --version
- name: Restore node_modules cache
id: restore-node-cache
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
if: steps.restore-node-cache.outputs.cache-hit != 'true'
run: |
echo "Installing dependencies..."
npm ci
- name: Cache node_modules
if: steps.restore-node-cache.outputs.cache-hit != 'true'
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('package-lock.json') }}
- name: Get AppBuilder Version
id: get_version
run: |
npx ts-node convert/fetchTags.ts >> $GITHUB_OUTPUT
- name: Restore Projects cache
id: restore-projects-cache
uses: actions/cache@v4
with:
path: project_data
key: ${{ runner.os }}-projects-${{ hashFiles('test_data/projects', 'convert/*.ts') }}-${{ steps.get_version.outputs.appbuilder_version }}
- name: Setup Java
if: steps.restore-projects-cache.outputs.cache-hit != 'true'
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
java-package: 'jdk'
- name: Install JFX
if: steps.restore-projects-cache.outputs.cache-hit != 'true'
uses: ConorMacBride/install-package@v1
with:
apt: openjfx libopenjfx-jni
- name: App Builders Install
if: steps.restore-projects-cache.outputs.cache-hit != 'true'
run: |
docker pull ghcr.io/sillsdev/app-builders:latest
container_id=$(docker create ghcr.io/sillsdev/app-builders:latest bash)
mkdir $HOME/app-builders
docker cp "$container_id:/" $HOME/app-builders
docker rm "$container_id"
chmod +x $HOME/app-builders/*.sh
java -version
$HOME/app-builders/sab.sh -? | head -n 4
- name: Convert Projects
if: steps.restore-projects-cache.outputs.cache-hit != 'true'
run: |
WORK_DIR=$(pwd)
mkdir project_data
for PROGRAM in sab dab; do
echo "Processing projects for $PROGRAM"
mkdir -p "$HOME/projects/$PROGRAM"
# Get all projects as JSON array
PROJECTS_JSON=$(jq -r ".${PROGRAM}.projects" "test_data/projects/index.json")
# Get number of projects
NUM_PROJECTS=$(echo "$PROJECTS_JSON" | jq '. | length')
# Iterate through projects using index
for ((i=0; i<$NUM_PROJECTS; i++)); do
# Get project path
PROJECT_ZIP=$(echo "$PROJECTS_JSON" | jq -r ".[$i].path")
PROJECT_NAME=$(basename "$PROJECT_ZIP" .zip)
echo "Project: $PROJECT_NAME"
PROJECT_DIR="$HOME/projects/${PROGRAM}/$PROJECT_NAME"
mkdir -p "$PROJECT_DIR"
unzip -q "test_data/projects/${PROGRAM}/$PROJECT_ZIP" -d "$PROJECT_DIR"
npm run clean:all > /dev/null
pushd "$PROJECT_DIR" > /dev/null
PROJECT_FILE=$(find . -type f -name "*.appDef")
"$HOME/app-builders/${PROGRAM}.sh" -load "$PROJECT_FILE" -build-modern-pwa-data-files -no-save -fp pwa-repo="$WORK_DIR" > /dev/null
popd > /dev/null
mkdir "project_data/$PROJECT_NAME"
mv data/* "project_data/$PROJECT_NAME"
du -h "project_data/$PROJECT_NAME"
done
done
du -h project_data
- name: Cache Extracted Projects
if: steps.restore-projects-cache.outputs.cache-hit != 'true'
uses: actions/cache@v4
with:
path: project_data
key: ${{ runner.os }}-projects-${{ hashFiles('test_data/projects', 'convert/*.ts') }}-${{ steps.get_version.outputs.appbuilder_version }}
lint:
runs-on: ubuntu-latest
needs: setup
steps:
- uses: actions/checkout@v4
- uses: volta-cli/action@v4
- name: Restore node_modules cache
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('package-lock.json') }}
- name: Restore Projects cache
uses: actions/cache@v4
with:
path: project_data
key: ${{ runner.os }}-projects-${{ hashFiles('test_data/projects', 'convert/*.ts') }}-${{ needs.setup.outputs.appbuilder_version }}
- name: Convert minimal project
run: |
npm run convert -- --data-dir=project_data/web_gospels
- name: TypeScript/Svelte Check
run: |
npm list --depth=0 typescript
npm run check
- name: ESLint
run: |
npm list --depth=0 eslint eslint-plugin-import prettier
npm run lint
- name: Run minimal build
run: |
npx vite build
test:
runs-on: ubuntu-latest
needs: setup
steps:
- uses: actions/checkout@v4
- uses: volta-cli/action@v4
- name: Restore node_modules cache
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('package-lock.json') }}
- name: Restore Projects cache
uses: actions/cache@v4
with:
path: project_data
key: ${{ runner.os }}-projects-${{ hashFiles('test_data/projects', 'convert/*.ts') }}-${{ needs.setup.outputs.appbuilder_version }}
- name: Run Tests
run: |
WORK_DIR=$(pwd)
for PROGRAM in sab dab; do
echo "Processing projects for $PROGRAM"
mkdir -p "$HOME/projects/$PROGRAM"
# Get all projects as JSON array
PROJECTS_JSON=$(jq -r ".${PROGRAM}.projects" "test_data/projects/index.json")
# Get number of projects
NUM_PROJECTS=$(echo "$PROJECTS_JSON" | jq '. | length')
# Iterate through projects using index
for ((i=0; i<$NUM_PROJECTS; i++)); do
# Get project path and test directories
PROJECT_ZIP=$(echo "$PROJECTS_JSON" | jq -r ".[$i].path")
TEST_DIRS=$(echo "$PROJECTS_JSON" | jq -r ".[$i].tests[]")
PROJECT_NAME=$(basename "$PROJECT_ZIP" .zip)
echo "Project: $PROJECT_NAME"
npm run clean:all > /dev/null
cp -r "project_data/$PROJECT_NAME/." data
npm run build
# Run tests for each specified directory
for TEST_DIR in $TEST_DIRS; do
echo "Running tests in directory: $TEST_DIR"
npm run test "$TEST_DIR"
done
done
done