Skip to content

Commit

Permalink
Upload build logs; post to Slack in the end; update build pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
arcatdmz committed Jun 26, 2024
1 parent 042a0fb commit d0a56ae
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 4 deletions.
28 changes: 24 additions & 4 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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/slack-github-action@v1.26.0
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 }}
3 changes: 3 additions & 0 deletions main.tex
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@
%% of authors' names for this purpose.
\renewcommand{\shortauthors}{Trovato et al.}

\newcommand{\systemname}{Griffith}

%%
%% The abstract is a short summary of the work to be presented in the
%% article.
Expand All @@ -208,6 +210,7 @@
article presents and explains many of the common variations, as well
as many of the formatting elements an author may use in the
preparation of the documentation of their work.
If I were to name this system, it should be \systemname.
\end{abstract}

%%
Expand Down
84 changes: 84 additions & 0 deletions scripts/abstract.js
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);

0 comments on commit d0a56ae

Please sign in to comment.