From 8739360d63f2577209e8621d2ebdcaf0427f4e23 Mon Sep 17 00:00:00 2001
From: Wouter Deconinck <wdconinc@gmail.com>
Date: Tue, 23 Aug 2022 23:42:55 +0000
Subject: [PATCH] fix: run Github workflow for docs inside alpine (LCG podio
 too old)

---
 .github/workflows/linux-eic-shell.yml | 53 ++++++++++++++++++++++++++-
 .github/workflows/linux-lcg.yml       | 32 ----------------
 CMakeLists.txt                        | 13 ++++---
 docs/Doxyfile.in                      |  8 ++--
 4 files changed, 64 insertions(+), 42 deletions(-)
 delete mode 100644 .github/workflows/linux-lcg.yml

diff --git a/.github/workflows/linux-eic-shell.yml b/.github/workflows/linux-eic-shell.yml
index 6461bd9..71fcbb3 100644
--- a/.github/workflows/linux-eic-shell.yml
+++ b/.github/workflows/linux-eic-shell.yml
@@ -1,6 +1,10 @@
 name: linux-eic-shell
 
-on: [push, pull_request]
+on:
+  push:
+  pull_request:
+  schedule:
+    - cron: '41 4 * * 0'
 
 jobs:
   build-test:
@@ -18,9 +22,56 @@ jobs:
     - uses: actions/upload-artifact@v3
       with:
         name: build-eic-shell
+        path: build/
+        if-no-files-found: error
+    - uses: actions/upload-artifact@v3
+      with:
+        name: install-eic-shell
         path: install/
         if-no-files-found: error
 
+  build-docs:
+    runs-on: ubuntu-latest
+    needs: build-test
+    container: alpine:latest
+    steps:
+    - uses: actions/checkout@v2
+    - uses: actions/download-artifact@v3
+      with:
+        name: build-eic-shell
+        path: build/
+    - run: |
+        apk add doxygen graphviz
+        doxygen build/Doxyfile
+    - uses: actions/upload-artifact@v3
+      with:
+        name: docs-eic-shell
+        path: build/docs/html/
+        if-no-files-found: error
+    - run: |
+        apk add bash
+        # FIXME tracking https://github.com/actions/upload-pages-artifact/pull/14
+    - uses: actions/upload-pages-artifact@v1
+      if: github.ref == 'refs/heads/master'
+      with:
+        path: build/docs/html/
+        retention-days: 7
+
+  deploy-docs:
+    needs: build-docs
+    if: github.ref == 'refs/heads/master'
+    permissions:
+      pages: write
+      id-token: write
+    environment:
+      name: github-pages
+      url: ${{ steps.deployment.outputs.page_url }}
+    runs-on: ubuntu-latest
+    steps:
+    - name: Deploy to GitHub Pages
+      id: deployment
+      uses: actions/deploy-pages@v1
+
   trigger-juggler:
     runs-on: ubuntu-latest
     needs: build-test
diff --git a/.github/workflows/linux-lcg.yml b/.github/workflows/linux-lcg.yml
deleted file mode 100644
index 74c87d3..0000000
--- a/.github/workflows/linux-lcg.yml
+++ /dev/null
@@ -1,32 +0,0 @@
-name: linux-lcg
-
-on:
-  push:
-    branches:
-      - master
-
-jobs:
-  build-lcg-docs:
-    runs-on: ubuntu-20.04
-    strategy:
-      fail-fast: false
-      matrix:
-        LCG: ["LCG_101/x86_64-ubuntu2004-gcc9-opt"]
-    steps:
-    - uses: actions/checkout@v3
-    - uses: cvmfs-contrib/github-action-cvmfs@v2
-      with:
-        cvmfs_repositories: 'sft.cern.ch,geant4.cern.ch'
-    - uses: aidasoft/run-lcg-view@v1
-      with:
-        release-platform: ${{ matrix.LCG }}
-        run: |
-          PREFIX=${PWD}/install
-          cmake -B build -S . -DCMAKE_INSTALL_PREFIX=${PREFIX}
-          cmake --build build -- install
-          cmake --build build -- docs
-    - uses: actions/upload-artifact@v3
-      with:
-        name: build-lcg-docs
-        path: build/docs/html/
-        if-no-files-found: error
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 75a36b4..302b111 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -68,14 +68,17 @@ install(FILES
 # -------------------------
 # install class documentation
 
+cmake_path(RELATIVE_PATH CMAKE_CURRENT_BINARY_DIR
+  OUTPUT_VARIABLE CMAKE_CURRENT_BINARY_RELATIVE_DIR)
+configure_file(
+  ${CMAKE_SOURCE_DIR}/docs/Doxyfile.in
+  ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
+  @ONLY)
+
 find_package(Doxygen COMPONENTS dot)
 if(DOXYGEN_FOUND)
-  configure_file(
-    ${CMAKE_SOURCE_DIR}/docs/Doxyfile.in
-    ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
-    @ONLY)
   add_custom_target(docs ALL
-    COMMAND doxygen ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
+    COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
     WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
     COMMENT "Generating API documentation with Doxygen"
     VERBATIM)
diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in
index 571d0ae..aa7ebee 100644
--- a/docs/Doxyfile.in
+++ b/docs/Doxyfile.in
@@ -58,7 +58,7 @@ PROJECT_BRIEF          = "EIC data model"
 # entered, it will be relative to the location where doxygen was started. If
 # left blank the current directory will be used.
 
-OUTPUT_DIRECTORY       = @CMAKE_CURRENT_BINARY_DIR@/docs
+OUTPUT_DIRECTORY       = @CMAKE_CURRENT_BINARY_RELATIVE_DIR@/docs
 
 # If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
 # directories (in 2 levels) under the output directory of each output format and
@@ -865,9 +865,9 @@ WARN_LOGFILE           =
 # Note: If this tag is empty the current directory is searched.
 
 INPUT                  = README.md \
-                         @CMAKE_CURRENT_BINARY_DIR@/src \
-                         @CMAKE_CURRENT_BINARY_DIR@/eicd \
-                         @CMAKE_CURRENT_BINARY_DIR@/utils
+                         @CMAKE_CURRENT_BINARY_RELATIVE_DIR@/src \
+                         @CMAKE_CURRENT_BINARY_RELATIVE_DIR@/eicd \
+                         @CMAKE_CURRENT_BINARY_RELATIVE_DIR@/utils
 
 # This tag can be used to specify the character encoding of the source files
 # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
-- 
GitLab