Skip to content

Commit

Permalink
fix: handle both prior 1.10 and 1.10+ metanorma actions-mn/build-and-…
Browse files Browse the repository at this point in the history
  • Loading branch information
CAMOBAP committed Jun 9, 2024
1 parent 885ffde commit 3f5539b
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 13 deletions.
49 changes: 47 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
- run: |
sudo apt-get install yamllint
yamllint action.yml
test-site-gen:
name: Test ./site-gen/ action on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
Expand All @@ -27,9 +28,9 @@ jobs:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: metanorma/mn-samples-iso
path: iso
Expand All @@ -45,3 +46,47 @@ jobs:
- uses: andstor/file-existence-action@v1
with:
files: iso/_site/index.html

test-before-1-10:
runs-on: ubuntu-latest
container:
image: metanorma/metanorma:1.9.7
steps:
- uses: actions/checkout@v4

- uses: actions/checkout@v4
with:
repository: metanorma/mn-samples-cc
path: cc

- uses: ./
with:
token: ${{ secrets.GITHUB_TOKEN }}
source-path: cc
agree-to-terms: true

- uses: andstor/file-existence-action@v1
with:
files: cc/_site/index.html

test-1-10:
runs-on: ubuntu-latest
container:
image: metanorma/metanorma:1.10.0
steps:
- uses: actions/checkout@v4

- uses: actions/checkout@v4
with:
repository: metanorma/mn-samples-cc
path: cc

- uses: ./
with:
token: ${{ secrets.GITHUB_TOKEN }}
source-path: cc
agree-to-terms: true

- uses: andstor/file-existence-action@v1
with:
files: cc/_site/index.html
75 changes: 64 additions & 11 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ inputs:
strict:
description: 'Run metanorma in strict mode'
default: '' # false
progress:
description: 'Display progress related logs'
default: 'false' # false
use-bundler:
description: 'Run in bundler'
default: '' # false
Expand All @@ -35,14 +38,64 @@ inputs:
runs:
using: "composite"
steps:
- shell: bash
run: |
cd ${{ inputs.source-path }}
${{ inputs.use-bundler == 'true' && 'bundle exec' || '' }} \
metanorma site generate . \
${{ inputs.strict && '--strict' || '' }} \
-o ${{ inputs.output-dir }} \
-c ${{ inputs.config-file }} \
${{ inputs.agree-to-terms && '--' || '--no-' }}agree-to-terms \
${{ inputs.install-fonts && '--' || '--no-' }}install-fonts \
${{ inputs.continue-without-fonts && '--' || '--no-' }}continue-without-fonts
- shell: bash
run: |
METANORMA_VERSION=$(${{ inputs.use-bundler == 'true' && 'bundle exec' || '' }} metanorma --version | head -1 | cut -d' ' -f2)
echo "METANORMA_VERSION=$METANORMA_VERSION" >> $GITHUB_ENV
- uses: actions/setup-python@v5
with:
python-version: '3.10'

- shell: python
run: |
import os
import sys
import json
import ensurepip
ensurepip.bootstrap()
try:
from packaging import version
except ImportError:
import pip
pip.main(['install', 'packaging'])
from packaging import version
flags = ''
legacy_flags = version.parse(os.getenv('METANORMA_VERSION')) < version.parse('1.10.0'):
inputs = json.loads("${{ toJSON(inputs) }}")
if inputs['strict'] == 'true':
flags += '--strict'
if inputs['progress'] != 'true':
flags += '--no-progress'
if inputs['agree-to-terms'] == 'true':
flags += '--agree-to-terms'
if inputs['install-fonts'] != 'true':
flags += '--no-install-fonts'
elif legacy_flags:
flags += '--no-no-install-fonts'
else:
flags += '--install-fonts'
if inputs['continue-without-fonts'] != 'true':
flags += '--no-continue-without-fonts'
elif legacy_flags:
flags += '--no-no-continue-without-fonts'
else:
flags += '--continue-without-fonts'
os.system(f"echo \"METANORMA_FLAGS={flags}\" >> {os.getenv('GITHUB_ENV')}")
- shell: bash
run: |
cd ${{ inputs.source-path }}
${{ inputs.use-bundler == 'true' && 'bundle exec' || '' }} \
metanorma site generate . \
-o ${{ inputs.output-dir }} \
-c ${{ inputs.config-file }} \
${{ env.METANORMA_FLAGS }}

0 comments on commit 3f5539b

Please sign in to comment.