Loading...
No commits yet
Not committed History
Blame
citation-style-test.yml • 3.7 KB
name: Citation Style Test

on:
  push:
    branches: [ main, develop ]
    paths:
      - '01_manuscript/**'
      - 'scripts/shell/**'
      - 'config/**'
      - 'shared/**'
      - 'scripts/installation/requirements/**'
      - '.github/workflows/citation-style-test.yml'
  pull_request:
    branches: [ main, develop ]
    paths:
      - '01_manuscript/**'
      - 'scripts/shell/**'
      - 'config/**'
      - 'shared/**'
      - 'scripts/installation/requirements/**'
      - '.github/workflows/citation-style-test.yml'

# Cancel in-progress runs when a new workflow with the same group name is triggered
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  test-citation-styles:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        style:
          - name: "Vancouver"
            value: "unsrtnat"
          - name: "IEEE"
            value: "IEEEtran"
          - name: "Nature"
            value: "naturemag"
          - name: "APA-like"
            value: "apalike"

    steps:
    - uses: actions/checkout@v4

    - name: Cache pip dependencies
      uses: actions/cache@v4
      with:
        path: ~/.cache/pip
        key: pip-${{ runner.os }}-xlsx2csv-csv2latex
        restore-keys: |
          pip-${{ runner.os }}-

    - name: Install dependencies
      run: |
        sudo apt-get update
        # Install core LaTeX packages (not full to save time)
        xargs sudo apt-get install -y < scripts/installation/requirements/system-debian.txt

        # Install yq (Go version)
        sudo wget -qO /usr/local/bin/yq \
          https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
        sudo chmod +x /usr/local/bin/yq

        # Install Python dependencies
        python3 -m pip install --upgrade pip
        pip install xlsx2csv csv2latex bibtexparser

    - name: Set citation style - ${{ matrix.style.name }}
      run: |
        echo "Testing citation style: ${{ matrix.style.name }} (${{ matrix.style.value }})"
        # Update config file with new citation style using yq wrapper
        ./scripts/shell/modules/yq_wrapper.sh set config/config_manuscript.yaml '.citation.style' "${{ matrix.style.value }}"
        # Verify the change
        echo "Current style in config:"
        ./scripts/shell/modules/yq_wrapper.sh get config/config_manuscript.yaml '.citation.style'

    - name: Compile manuscript with ${{ matrix.style.name }} style
      run: ./compile.sh manuscript

    - name: Verify citation style was applied
      run: |
        echo "Checking bibliography.tex for active style:"
        grep '^\bibliographystyle' shared/latex_styles/bibliography.tex || echo "No active style found"

    - name: Upload PDF with ${{ matrix.style.name }} style
      uses: actions/upload-artifact@v4
      if: success()
      with:
        name: manuscript-${{ matrix.style.name }}
        path: 01_manuscript/manuscript.pdf
        retention-days: 30

    - name: Upload compilation log
      uses: actions/upload-artifact@v4
      if: always()
      with:
        name: compilation-log-${{ matrix.style.name }}
        path: 01_manuscript/logs/global.log
        retention-days: 7

  compare-results:
    needs: test-citation-styles
    runs-on: ubuntu-latest
    if: success()

    steps:
    - name: Download all artifacts
      uses: actions/download-artifact@v4

    - name: List generated PDFs
      run: |
        echo "=== Citation Style Test Results ==="
        echo "Successfully compiled manuscripts with the following citation styles:"
        ls -lh manuscript-*/manuscript.pdf
        echo ""
        echo "All citation styles compiled successfully!"
        echo "PDFs are available in the artifacts section above."