-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upload build logs; post to Slack in the end; update build pipelines
- Loading branch information
Showing
3 changed files
with
111 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,10 @@ on: | |
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
env: | ||
SYSTEM_NAME_COMMAND: systemname | ||
SYSTEM_NAME: Griffith | ||
|
||
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | ||
permissions: | ||
contents: read | ||
|
@@ -30,14 +34,30 @@ jobs: | |
container: arcatdmz/texlive | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
uses: actions/checkout@v4 | ||
- name: Build PDF file | ||
run: latexmk -pdf && latexmk -c && mkdir -p docs && cp *.pdf ./docs/ | ||
run: latexmk -pdf | ||
- name: Run scripts | ||
run: apt update && apt install -y nodejs && node scripts/abstract.js > abstract.log | ||
- name: Organize files to upload | ||
run: mkdir -p docs && cp *.pdf *.log ./docs/ | ||
- name: Upload artifact | ||
uses: actions/upload-pages-artifact@v1 | ||
uses: actions/upload-pages-artifact@v3 | ||
with: | ||
# Upload "docs" directory | ||
path: "docs" | ||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v1 | ||
uses: actions/deploy-pages@v4 | ||
- name: Post to a Slack channel | ||
# It's possible to post messages only when the build fails (or succeeds) | ||
# if: failure() | ||
uses: slackapi/[email protected] | ||
with: | ||
channel-id: ${{ secrets.SLACK_CHANNEL_CI }} | ||
slack-message: | | ||
New PDF file was generated | ||
- GitHub Actions URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | ||
- GitHub Pages URL: ${{ steps.deployment.outputs.page_url }} | ||
env: | ||
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
const fs = require("fs"); | ||
|
||
// The following script is a slight modification from the abstract extraction tool by Ruofei Du: | ||
// https://tool.duruofei.com/abstract/ | ||
|
||
const sysinExp = `\\${process.env.SYSTEM_NAME_COMMAND || "systemname"}`; | ||
const sysout = process.env.SYSTEM_NAME || "Geollery"; | ||
|
||
function WordCount(str) { | ||
return str.split(/\s+/).length; | ||
} | ||
|
||
function Analyze(a) { | ||
var res = a.trim(); | ||
// begin re_abstract | ||
const startWord = "\\begin{abstract}"; | ||
let start = res.indexOf(startWord), | ||
end = res.indexOf("\\end{abstract"); | ||
if (start >= 0 && end >= start) { | ||
res = res.substring(start + startWord.length, end).trim(); | ||
} | ||
|
||
// ieee \re_abstract | ||
re_abs = /\\re_abstract{(.+)}/gm; | ||
match = re_abs.exec(res); | ||
if (match && match[1]) { | ||
res = match[1]; | ||
} | ||
|
||
// citations | ||
res = res.replace(/\\cite\{[\w\d,:]+\}/g, ""); | ||
res = res.replace(/\\ref\{[\w\d,:]+\}/g, "X"); | ||
res = res.replace(/\\begin\{[\w\d,:]+\}\[.+\]/g, ""); | ||
res = res.replace(/\\end\{[\w\d,:]+\}/g, ""); | ||
res = res.replace(/\\label\{[\w\d,:]+\}/g, ""); | ||
res = res.replace(/\\centering/g, ""); | ||
res = res.replace(/\\caption/g, ""); | ||
res = res.replace(/\\LaTeX\\/g, "LaTeX"); | ||
res = res.replace( | ||
/\\includegraphics[\[\w\d\,\.\:\=\/\\]+\]\{[\w\d,\.\:\/\\\_]+\}/g, | ||
"" | ||
); | ||
|
||
// latex symbols | ||
res = res.replace(/\\degree/g, "°"); | ||
res = res.replace(/\\times/g, "×"); | ||
res = res.replace(/\\etal/g, "et al."); | ||
res = res.replace(/``/g, '"'); | ||
res = res.replace(/""/g, '"'); | ||
res = res.replace(/\'\'/g, '"'); | ||
res = res.replace(/\\&/g, "&"); | ||
res = res.replace(/ \./g, "."); | ||
let sysin = new RegExp("\\" + sysinExp, "g"); | ||
res = res.replace(sysin, sysout); | ||
|
||
// comments | ||
res = res.replace(/([^\\]|^)%.+/gm, ""); // Fixed for Firefox | ||
|
||
// emph and italics | ||
res = res.replace(/\{\\\w+/gm, "").replace(/\\\/\}/g, ""); | ||
|
||
// textit, $, and ~ | ||
res = res | ||
.replace(/\\\w+{/gm, "") | ||
.replace(/[\}\$]/g, "") | ||
.replace(/\~/g, " "); | ||
res = res.replace(/\\sim/g, "~"); | ||
|
||
// double white spaces | ||
res = res.replace(/\n/g, " "); | ||
res = res.replace(/\s\s+/g, " "); | ||
res = res.replace(/([\.,])(\s)([\.,])/g, "$1$3"); | ||
|
||
// \% percentage | ||
res = res.replace(/\\\%/g, "%"); | ||
res = res.trim(); | ||
|
||
return { wc: WordCount(res), res }; | ||
} | ||
|
||
const content = fs.readFileSync("main.tex", { encoding: "utf8" }); | ||
const { wc, res } = Analyze(content); | ||
console.log("Word count: %d", wc); | ||
console.log(res); |