Skip to content

Commit

Permalink
infra: modified .github folder
Browse files Browse the repository at this point in the history
infra: deleted Remark-GFM
  • Loading branch information
santi100a committed Aug 30, 2023
1 parent fdec1dc commit 4c5b60c
Show file tree
Hide file tree
Showing 21 changed files with 1,787 additions and 8,889 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: santi100a
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ updates:
- package-ecosystem: npm # See documentation for possible values
directory: / # Location of package manifests
schedule:
interval: weekly
interval: daily
2 changes: 1 addition & 1 deletion .github/workflows/check-md-links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ jobs:
node-version: 19.x
- name: Install dependencies
run: yarn
- name: Run link check
- name: Run link check
run: yarn check-links
9 changes: 6 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,18 @@ jobs:

- name: Run ESLint
if: env.IS_RELEASE_COMMIT == '1'
run: yarn lint
run: |
yarn lint
- name: Build source code
if: env.IS_RELEASE_COMMIT == '1'
run: yarn build
run: |
yarn build
- name: Run test suites
if: env.IS_RELEASE_COMMIT == '1'
run: yarn test
run: |
yarn test
release:
if: needs.test.outputs.IS_RELEASE_COMMIT == '1'
permissions:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/issue-welcome.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ permissions:
issues: write
jobs:
welcome-author:
continue-on-error: true
runs-on: ubuntu-latest
steps:
- name: Say hi
Expand All @@ -17,6 +16,7 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
issue_number: ${{ github.event.issue.number }}
body: |
Hi, ${{ github.actor }}!
Make sure to comply with the [Code of Conduct](
https://github.com/${{ github.repository }}/blob/main/CODE_OF_CONDUCT.md),
[security policy](https://github.com/${{ github.repository }}/blob/main/SECURITY.md)
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/pr-build-failed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ on:
type: string
jobs:
report-pr-build-failed:
continue-on-error: true
permissions:
pull-requests: write
runs-on: ubuntu-latest
Expand Down
125 changes: 97 additions & 28 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,49 @@ name: Pull Request check
on:
pull_request:
types:
- edited
- opened
- synchronize
paths:
- src/**/*.*
jobs:
say-hi:
continue-on-error: true
permissions:
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Check for existence of comment
id: comment
run: |
yarn init --yes
yarn add --optional @octokit/[email protected]
node --eval="
(async function() {
const { Octokit } = require('@octokit/rest');
const github = new Octokit({ auth: process.env.GITHUB_TOKEN });
const issueNumber = '${{ github.event.pull_request.number }}';
const owner = '${{ github.repository_owner }}';
const repo = '${{ github.repository }}'.replace(owner + '/', '');
const { data: comments } = await github.issues.listComments({
owner,
repo,
issue_number: issueNumber,
});
console.log(comments.some(comment => comment.body.includes('Hi, ${{ github.actor }}')));
})();
" >> hi.txt
echo "result=$(cat hi.txt | grep -E 'true|false')" >> $GITHUB_OUTPUT
- name: Say hi
uses: jungwinter/comment@v1
if: steps.comment.outputs.result == 'false'
with:
type: create
token: ${{ secrets.GITHUB_TOKEN }}
issue_number: ${{ github.event.pull_request.number }}
body: |
Hi, ${{ github.actor }}!
Make sure to comply with the [Code of Conduct](https://github.com/${{ github.repository }}/blob/main/CODE_OF_CONDUCT.md), [security policy](https://github.com/${{ github.repository }}/blob/main/SECURITY.md) and [contribution guidelines](https://github.com/${{ github.repository }}/blob/main/CONTRIBUTING.md) before contributing to this repo.
test:
permissions:
pull-requests: write
Expand All @@ -23,48 +60,80 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Clone the main repo
run: |
cd ..
sudo /usr/bin/git clone https://github.com/${{ github.repository }} main
(cd -) > /dev/null
- name: Pre-run modified files validation
run: |
sudo chmod +x scripts/validate-diff.sh
scripts/validate-diff.sh .github ../main/.github
scripts/validate-diff.sh LICENSE ../main/LICENSE
scripts/validate-diff.sh .gitignore ../main/.gitignore
scripts/validate-diff.sh .prettierrc ../main/.prettierrc
scripts/validate-diff.sh .eslintrc.json ../main/.eslintrc.json
scripts/validate-diff.sh tsconfig.json ../main/tsconfig.json
scripts/validate-diff.sh SECURITY.md ../main/SECURITY.md
scripts/validate-diff.sh CONTRIBUTING.md ../main/CONTRIBUTING.md
scripts/validate-diff.sh CODE_OF_CONDUCT.md ../main/CODE_OF_CONDUCT.md
- name: Get rid of the main repo's clone
run: sudo rm -rf ../main
- name: Install dependencies
run: yarn

- name: Validate package.json
run: yarn validate-package-json

- name: Validate Markdown links
run: yarn check-links

- name: Run ESLint
run: yarn lint

- name: Build code
run: yarn build

- name: Run main test suites
run: yarn test

- name: Checkout main
run: git clone https://github.com/${{ github.repository }} main/
- name: Report build failed (if any)
if: failure()
uses: ./.github/workflows/pr-build-failed.yml
uses: ./main/.github/workflows/pr-build-failed.yml
with:
pr-author: ${{ github.event.pull_request.user.login }}
number: ${{ github.event.pull_request.number }}
assign-and-ping:
runs-on: ubuntu-latest
continue-on-error: true
needs: test
if: success()
permissions:
pull-requests: write
issues: write
steps:
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: 19.x

- name: Assign pull request to yourself
run: |
yarn init --yes
yarn add --optional @octokit/[email protected]
node --eval="
const { Octokit } = require('@octokit/rest');
const github = new Octokit({ auth: process.env.GITHUB_TOKEN });
(async function() {
await github.issues.addAssignees({
owner: '${{ github.repository_owner }}',
repo: '${{ github.repository }}'.replace('${{ github.repository_owner }}/', ''),
issue_number: ${{ github.event.pull_request.number }},
assignees: ['${{ github.repository_owner }}'],
});
})();
"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Request code review
run: |
yarn init --yes
yarn add --optional @octokit/[email protected]
node --eval="
const { Octokit } = require('@octokit/rest');
const github = new Octokit({ auth: process.env.GITHUB_TOKEN });
(async function() {
await github.pulls.requestReviewers({
owner: '${{ github.repository_owner }}',
repo: '${{ github.repository }}'.replace('${{ github.repository_owner }}/', ''),
pull_number: ${{ github.event.pull_request.number }},
reviewers: ['${{ github.repository_owner }}'],
});
})();
"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26 changes: 0 additions & 26 deletions .github/workflows/pr-welcome.yml

This file was deleted.

1 change: 0 additions & 1 deletion .remarkrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"plugins": [
"gfm",
"validate-links"
]
}
58 changes: 57 additions & 1 deletion colorize-template.js
Original file line number Diff line number Diff line change
@@ -1 +1,57 @@
module.exports = require('./cjs/colorize-template');
"use strict";
exports.__esModule = true;
exports.colorizeTemplate = void 0;
var assertion_lib_1 = require("@santi100/assertion-lib");
var core_1 = require("./core");
/**
* Fills `str`, given that it is a template like this:
* ```colortemp
* text %color,effect(more text) and more text
* ```
*
* @param template The template string to fill.
* @returns The template string with all placeholders replaced with the correct colors or effects.
*/
function colorizeTemplate(template) {
(0, assertion_lib_1.assertTypeOf)(template, 'string', 'str');
var output = '';
var i = 0;
while (i < template.length) {
if (template[i] === '%') {
if (template[i + 1] === '%') {
output += '%';
i += 2;
continue;
}
var j = template.indexOf('(', i);
if (j === -1) {
throw new SyntaxError('Invalid template: missing opening parenthesis');
}
var k = template.indexOf(')', j);
if (k === -1) {
throw new SyntaxError('Invalid template: missing closing parenthesis');
}
var directive = template.slice(i + 1, j);
var _a = directive.split(/,\s*/), color = _a[0], effects = _a.slice(1);
if (!core_1.COLORS[color]) {
throw new Error("Invalid color: ".concat(color));
}
var colorCode = core_1.COLORS[color];
for (var _i = 0, effects_1 = effects; _i < effects_1.length; _i++) {
var effect = effects_1[_i];
var trimmedEffect = effect.trim();
if (!core_1.EFFECTS[trimmedEffect]) {
throw new Error("Invalid effect: ".concat(trimmedEffect));
}
colorCode += core_1.EFFECTS[trimmedEffect];
}
output += "".concat(colorCode).concat(template.slice(j + 1, k), "\u001B[0m");
i = k + 1;
continue;
}
output += template[i];
i++;
}
return output;
}
exports.colorizeTemplate = colorizeTemplate;
61 changes: 60 additions & 1 deletion colorize.js
Original file line number Diff line number Diff line change
@@ -1 +1,60 @@
module.exports = require('./cjs/colorize');
"use strict";
exports.__esModule = true;
exports.colorize = exports.coloring = void 0;
var assertion_lib_1 = require("@santi100/assertion-lib");
var core_1 = require("./core");
var warn = typeof console === 'undefined' ? function () { return void 0; } : console.warn;
var log = typeof console === 'undefined' ? function () { return void 0; } : console.log;
var warnOrLog = warn !== null && warn !== void 0 ? warn : log;
function __keys(o) {
if (Object === null || Object === void 0 ? void 0 : Object.keys)
return Object.keys(o);
else {
var keys = [];
for (var key in o) {
keys.push(key);
}
return keys;
}
}
/**
* Color `str` with color(s) `color`.
*
* @param str The string to paint in color!
* @param color The color(s) to paint the string in.
*/
function colorize(str, color) {
(0, assertion_lib_1.assertTypeOf)(str, 'string', 'str');
if (!(color instanceof Array)) {
(0, assertion_lib_1.assertTypeOf)(color, 'string', 'color');
(0, assertion_lib_1.assertOneOf)(color, 'color', __keys(core_1.COLORS_AND_EFFECTS));
}
function generateFromArray(color) {
var j = '';
for (var _i = 0, color_1 = color; _i < color_1.length; _i++) {
var item = color_1[_i];
j += core_1.COLORS_AND_EFFECTS[item];
}
j += "".concat(str, "\u001B[0m");
return j;
}
return typeof color === 'string'
? "".concat(core_1.COLORS_AND_EFFECTS[color]).concat(str, "\u001B[0m")
: generateFromArray(color);
}
exports["default"] = colorize;
exports.colorize = colorize;
/**
* @deprecated This is a deprecated alias for the main `colorize` function. Use {@link colorize} instead.
*/
function coloring() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
warnOrLog('coloring() is deprecated. Use colorize() instead.');
return typeof args[1] !== 'string'
? colorize(args[0], args[1])
: colorize(args[0], args[1]);
}
exports.coloring = coloring;
Loading

0 comments on commit 4c5b60c

Please sign in to comment.