Skip to content

test: wrong alphabetical order #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 33 commits into
base: gh-action-2
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
45289ab
test: wrong alphabetical order
LuigiImVector Jul 12, 2022
f186b02
test: wrong alphabetical order (double)
LuigiImVector Jul 12, 2022
15a28b2
fix(fpb-lint): every step must define a `uses` or `run` key
LuigiImVector Jul 12, 2022
8e089e3
build(fpb-lint): added else condition
LuigiImVector Jul 12, 2022
06f5245
test: debug order
LuigiImVector Jul 12, 2022
fba3615
fix: added callback function to writeFile()
LuigiImVector Jul 12, 2022
3d697bd
fix: missed parentheses
LuigiImVector Jul 12, 2022
67b9af5
typo
LuigiImVector Jul 12, 2022
5ac50ca
fix: replaced 'writeFile' with 'appendFile'
LuigiImVector Jul 12, 2022
2649a9c
newline
LuigiImVector Jul 12, 2022
a883ef6
build(fpb-lint): cleaned output
LuigiImVector Jul 12, 2022
c658a3b
build(fpb-lint): remove newline from the eof
LuigiImVector Jul 12, 2022
2ea0b80
build(fpb-lint): ignore newlines at the eof
LuigiImVector Jul 12, 2022
691b511
build(fpb-lint): remove newlines at the eof
LuigiImVector Jul 12, 2022
83346dc
fix: use \r\n instead of \n
LuigiImVector Jul 12, 2022
dcbad89
fix
LuigiImVector Jul 12, 2022
6ef2848
test
LuigiImVector Jul 12, 2022
a8652a4
test: two different file with errors
LuigiImVector Jul 12, 2022
3fa3689
fix: removing newlines
LuigiImVector Jul 13, 2022
060f1b9
build(fpb-lint): removed bash code for the for removing newlines ata …
LuigiImVector Jul 13, 2022
30c10bb
test: new cleaning script
LuigiImVector Jul 13, 2022
7272127
fix: properties undefined
LuigiImVector Jul 13, 2022
9f734d9
fix: lastLine undefined
LuigiImVector Jul 13, 2022
0e2fad7
build(fpb-lint): cleaning output using Node.js
LuigiImVector Jul 13, 2022
505b2a5
test: two alphabetical errors fixed
LuigiImVector Jul 13, 2022
2bc611f
test: last alphabetical error fixed
LuigiImVector Jul 13, 2022
62f553e
build: uses two different workflows
LuigiImVector Jul 13, 2022
93de433
typo
LuigiImVector Jul 13, 2022
9e8ddd5
typo folder
LuigiImVector Jul 13, 2022
f81d24f
build(commentPr): use actions/download-artifact@v3
LuigiImVector Jul 13, 2022
987e043
last line
LuigiImVector Jul 13, 2022
21f8908
build(commentPr): stop using action/download-artifact@v3
LuigiImVector Jul 13, 2022
712cd88
test: add new errors :)
LuigiImVector Jul 13, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/commentPr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Comment on the pull request

on:
workflow_run:
workflows: ["free-programming-books-lint"]
types:
- completed

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
upload:
runs-on: ubuntu-latest
if: >
${{ github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success' }}
steps:
- name: 'Download artifact'
uses: actions/github-script@v6
with:
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "pr"
})[0];
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/pr.zip`, Buffer.from(download.data));

- name: 'Unzip artifact'
run: unzip pr.zip
- name: 'Comment on PR'
run: |
cat error.log
if [ -s error.log ]
then
gh pr review $(<PRurl) -r -b "Linter failed, fix the error(s):
\`\`\`
$(cat error.log)
\`\`\`"
gh pr edit $(<PRurl) --add-label "linter error"
else
gh pr review $(<PRurl) -a
gh pr edit $(<PRurl) --remove-label "linter error"
fi
77 changes: 44 additions & 33 deletions .github/workflows/fpb-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,13 @@ name: free-programming-books-lint

on: [push, pull_request]

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_RUN_ID: ${{ github.run_id }}
PR: ${{ github.event.pull_request.html_url }}

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Use Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Use Github Script
uses: actions/github-script@v6
- name: Use Node.js
uses: actions/setup-node@v3
with:
Expand All @@ -43,42 +32,64 @@ jobs:
fpb-lint ./courses/ &>> output.log || echo "Analyzing..."
fpb-lint ./more/ &>> output.log || echo "Analyzing..."

touch error.log

- name: Clean output
if: ${{ always() &&
github.event_name == 'pull_request' }}
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const readline = require('readline');

const file = readline.createInterface({
input: fs.createReadStream('output.log'),
output: process.stdout,
terminal: false
input: fs.createReadStream('output.log'),
output: process.stdout,
terminal: false,
});

let lastLine = '';
file.on('line', (line) => {
if (line.includes('/home/runner/work/free-programming-books/')) {
fs.writeFile('error.log', line.replace('/home/runner/work/free-programming-books/', ''));
} else if (line.includes('\u26a0')) {
fs.writeFile('error.log', '\n\n');
if (lastLine) {
fs.appendFile('error.log', lastLine, (err) => {
if (err) {
console.error(err);
}
});
}

if (line.includes('/home/runner/work/free-programming-books/')) {
lastLine = line.replace('/home/runner/work/free-programming-books/', '') + "\r\n";
} else if (line.includes('\u26a0')) {
lastLine = '\r\n\r\n';
} else if (line.includes('remark-lint')) {
lastLine = line + '\r\n';
} else {
lastLine = null;
}
});

file.on('close', () => {
if (!lastLine || lastLine === '\r\n\r\n') {
return;
}

fs.appendFile('error.log', lastLine, (err) => {
if (err) {
console.error(err);
}
});
});

- name: Print output
- name: Upload artifact
if: ${{ always() &&
github.event_name == 'pull_request' }}
run: |
cat error.log

if [ -s error.log ]
then
gh pr review $PR -r -b "Linter failed, fix the error(s):
\`\`\`
$(cat error.log)
\`\`\`"
gh pr edit $PR --add-label "linter error"
else
gh pr review $PR -a
gh pr edit $PR --remove-label "linter error"
fi
mkdir -p ./pr
echo ${{ github.event.pull_request.html_url }} > ./pr/PRurl
mv error.log ./pr/error.log
- uses: actions/upload-artifact@v3
with:
name: pr
path: pr/
2 changes: 1 addition & 1 deletion books/free-programming-books-langs.md
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ That section got so big, we decided to split it into its own file, the [BY SUBJE
* [Bash Guide for Beginners (2008)](http://www.tldp.org/LDP/Bash-Beginners-Guide/html/) - M. Garrels (HTML)
* [Bash Notes for Professionals](http://goalkicker.com/BashBook/) - Compiled from StackOverflow documentation (PDF)
* [BASH Programming (2000)](http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html) - Mike G. (HTML)
* [Bash Reference Manual](http://www.gnu.org/software/bash/manual/bashref.html) (HTML)
* [ABash Reference Manual](http://www.gnu.org/software/bash/manual/bashref.html) (HTML)
* [Bash tutorial](https://web.archive.org/web/20180328183806/http://gdrcorelec.ups-tlse.fr/files/bash.pdf) - Anthony Scemama (PDF)
* [BashGuide](http://mywiki.wooledge.org/BashGuide) - Maarten Billemont (HTML) [(PDF)](http://s.ntnu.no/bashguide.pdf)
* [Conquer the Command Line](https://magpi.raspberrypi.org/books/command-line-second-edition/pdf/download) - Richard Smedley (PDF)
Expand Down