diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml index 90fa1c83a..390f82810 100644 --- a/.gitea/workflows/test.yml +++ b/.gitea/workflows/test.yml @@ -179,95 +179,95 @@ jobs: env: CI_TOKEN: ${{ secrets.CI_TOKEN }} - wiki: - needs: tests - runs-on: ubuntu-latest + wiki: + needs: tests + runs-on: ubuntu-latest - steps: - - name: Checkout main repository - uses: actions/checkout@v4 + steps: + - name: Checkout main repository + uses: actions/checkout@v4 - - name: Get commit info - id: info - run: | - short_sha=$(git rev-parse --short HEAD) - commit_msg=$(git log -1 --pretty=%B) + - name: Get commit info + id: info + run: | + short_sha=$(git rev-parse --short HEAD) + commit_msg=$(git log -1 --pretty=%B) + commit_num=$(echo "$commit_msg" | grep -oE '#[0-9]+' | head -n1 || echo "") - echo "🔍 Commit SHA: $short_sha" - echo "🔍 Commit message: $commit_msg" + echo "🔍 Commit SHA: $short_sha" + echo "🔍 Commit message: $commit_msg" + echo "🔍 Commit PR #: $commit_num" - echo "short_sha=$short_sha" >> $GITHUB_OUTPUT - echo "commit_num=$commit_num" >> $GITHUB_OUTPUT + echo "short_sha=$short_sha" >> $GITHUB_OUTPUT + echo "commit_num=$commit_num" >> $GITHUB_OUTPUT - - name: Clone Gitea Wiki - run: | - echo "📚 Cloning wiki repo: https://gitea.psi.ch/tligui_y/slic.wiki.git" - git clone https://ci-token:${{ secrets.CI_TOKEN }}@gitea.psi.ch/tligui_y/slic.wiki.git wiki > wiki_clone.log 2>&1 || { - echo "❌ Wiki clone failed" - cat wiki_clone.log | grep -i 'error\|fatal' - exit 1 - } - echo "✅ Wiki cloned to ./wiki" + - name: Clone Gitea Wiki + run: | + echo "📚 Cloning wiki repo" + git clone https://ci-token:${{ secrets.CI_TOKEN }}@gitea.psi.ch/tligui_y/slic.wiki.git wiki > wiki_clone.log 2>&1 || { + echo "❌ Wiki clone failed" + cat wiki_clone.log | grep -i 'error\|fatal' + exit 1 + } + echo "✅ Wiki cloned to ./wiki" - - name: Copy reports into wiki - run: | - echo "📝 Creating wiki markdown files..." + - name: Create and copy reports into wiki + run: | + echo "📝 Creating wiki markdown files..." - REPO_URL="https://gitea.psi.ch/tligui_y/slic" - RUN_LINK="${REPO_URL}/actions/runs/${GITHUB_RUN_NUMBER}" - SHORT_SHA=$(git rev-parse --short HEAD) - COMMIT_MSG=$(git log -1 --pretty=%s | tr -d '\n' | cut -c1-80) + REPO_URL="https://gitea.psi.ch/tligui_y/slic" + RUN_LINK="${REPO_URL}/actions/runs/${GITHUB_RUN_NUMBER}" + SHORT_SHA=$(git rev-parse --short HEAD) + COMMIT_MSG=$(git log -1 --pretty=%s | tr -d '\n' | cut -c1-80) - SAFE_TITLE=$(echo "$COMMIT_MSG" | tr ' /\\:*?"<>|' '-' | tr -cd '[:alnum:] -' | sed 's/ */ /g' | sed 's/ *$//') + SAFE_TITLE=$(echo "$COMMIT_MSG" | tr ' /\\:*?"<>|' '-' | tr -cd '[:alnum:] -' | sed 's/ */ /g' | sed 's/ *$//') - TEST_MD_PATH="wiki/run-${GITHUB_RUN_NUMBER}-TEST-REPORT----commit:-${SHORT_SHA}--with-message:-${SAFE_TITLE}.md" - COVERAGE_MD_PATH="wiki/run-${GITHUB_RUN_NUMBER}-COVERAGE-FILE----commit:-${SHORT_SHA}--with-message:-${SAFE_TITLE}.md" + TEST_MD_PATH="wiki/run-${GITHUB_RUN_NUMBER}-TEST-REPORT-commit-${SHORT_SHA}-message-${SAFE_TITLE}.md" + COVERAGE_MD_PATH="wiki/run-${GITHUB_RUN_NUMBER}-COVERAGE-REPORT-commit-${SHORT_SHA}-message-${SAFE_TITLE}.md" - echo "📄 Wiki files will be:" - echo " - $TEST_MD_PATH" - echo " - $COVERAGE_MD_PATH" + echo "🕒 Source TEST-REPORT.md last modified:" + stat ci-reports/markdown/TEST-REPORT.md + echo "🔍 Source TEST-REPORT.md preview:" + head -n 10 ci-reports/markdown/TEST-REPORT.md - { - echo "**🔗 View CI run logs for commit \`${SHORT_SHA}\` - run [#${GITHUB_RUN_NUMBER}](${RUN_LINK})**" - echo "**📝 Commit:** \`$COMMIT_MSG\`" - echo "" - cat ci-reports/markdown/TEST-REPORT.md - } > "$TEST_MD_PATH" + cp -f ci-reports/markdown/TEST-REPORT.md "$TEST_MD_PATH" + cp -f ci-reports/markdown/coverage-summary.md "$COVERAGE_MD_PATH" - { - echo "**🔗 View CI run logs for commit \`${SHORT_SHA}\` - run [#${GITHUB_RUN_NUMBER}](${RUN_LINK})**" - echo "**📝 Commit:** \`$COMMIT_MSG\`" - echo "" - cat ci-reports/markdown/coverage-summary.md - } > "$COVERAGE_MD_PATH" + touch "$TEST_MD_PATH" "$COVERAGE_MD_PATH" - echo "✅ Wiki files created:" - echo " - $TEST_MD_PATH" - echo " - $COVERAGE_MD_PATH" + echo "🕒 Wiki TEST-REPORT.md last modified:" + stat "$TEST_MD_PATH" + echo "🔍 Wiki TEST-REPORT.md preview:" + head -n 10 "$TEST_MD_PATH" + echo "✅ Wiki files created:" + echo " - $TEST_MD_PATH" + echo " - $COVERAGE_MD_PATH" + - name: Commit and push to wiki + run: | + echo "📤 Preparing to commit and push wiki reports..." + cd wiki + git config user.name "ci-bot" + git config user.email "ci-bot@example.com" - - name: Commit and push to wiki - run: | - echo "📤 Committing and pushing wiki reports..." - cd wiki - git config user.name "ci-bot" - git config user.email "ci-bot@example.com" - git add . + git status - COMMIT_MSG="Add wiki reports for ${{ steps.info.outputs.short_sha }} ${{ steps.info.outputs.commit_num }}" - git commit -m "$COMMIT_MSG" || echo "⚠️ Nothing to commit" + git add "$TEST_MD_PATH" "$COVERAGE_MD_PATH" - echo "🚀 Pushing to wiki: https://gitea.psi.ch/tligui_y/slic.wiki.git" - git push https://ci-token:${{ secrets.CI_TOKEN }}@gitea.psi.ch/tligui_y/slic.wiki.git HEAD:main > push_wiki.log 2>&1 || { - echo "❌ Push to wiki failed" - cat push_wiki.log | grep -i 'error\|fatal\|refused' - exit 1 - } + COMMIT_MSG="Add wiki reports for ${{ steps.info.outputs.short_sha }} ${{ steps.info.outputs.commit_num }}" + git commit -m "$COMMIT_MSG" || echo "⚠️ Nothing to commit" - echo "✅ Wiki reports pushed" - echo "🔗 View in Wiki:" - echo " - $REPO_URL/wiki/${TEST_MD_PATH#wiki/}" - echo " - $REPO_URL/wiki/${COVERAGE_MD_PATH#wiki/}" - env: - CI_TOKEN: ${{ secrets.CI_TOKEN }} \ No newline at end of file + echo "🚀 Pushing wiki to https://gitea.psi.ch/tligui_y/slic.wiki.git" + git push https://ci-token:${{ secrets.CI_TOKEN }}@gitea.psi.ch/tligui_y/slic.wiki.git HEAD:main > push_wiki.log 2>&1 || { + echo "❌ Push to wiki failed" + cat push_wiki.log | grep -i 'error\|fatal\|refused' + exit 1 + } + + echo "✅ Wiki reports pushed" + echo "🔗 Wiki URLs:" + echo " - $REPO_URL/wiki/${TEST_MD_PATH#wiki/}" + echo " - $REPO_URL/wiki/${COVERAGE_MD_PATH#wiki/}" + env: + CI_TOKEN: ${{ secrets.CI_TOKEN }}