Skip to content

Commit

Permalink
feat: version 0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
santi100a committed May 27, 2023
1 parent 1f0b86c commit 523f7d3
Show file tree
Hide file tree
Showing 22 changed files with 2,404 additions and 261 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@
"eslint-plugin-jest"
],
"rules": {
"@typescript-eslint/no-var-requires": "off",
"no-console": "warn"
}
}
19 changes: 19 additions & 0 deletions .github/workflows/check-md-links.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Check for broken Markdown links

on:
schedule:
- cron: 0 0 * * *
workflow_dispatch: {}

jobs:
check-links:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 19.x
- name: Install dependencies
run: yarn
- name: Run link check
run: yarn check-links
35 changes: 25 additions & 10 deletions .github/workflows/main.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:

jobs:
test:
outputs:
rel: ${{ steps.commit.outputs.rel }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -17,9 +19,28 @@ jobs:
node-version: 19.x
always-auth: true

- name: Check commit message
id: commit
run: |
COMMIT_MSG=$(/usr/bin/git log --format=%B -n 1 HEAD)
STRING=$(echo $COMMIT_MSG | (grep -E "infra:|docs:|lint:|code-style:" || echo ''))
if [ -z "$STRING" ]; then
echo "rel=1" >> $GITHUB_OUTPUT
echo "IS_RELEASE_COMMIT=1" >> $GITHUB_ENV
else
echo "This commit will NOT trigger a release."
echo "rel=0" >> $GITHUB_OUTPUT
echo "IS_RELEASE_COMMIT=0" >> $GITHUB_ENV
fi
- name: Install dependencies
run: yarn

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

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

Expand All @@ -32,9 +53,10 @@ jobs:
- name: Run test suites
run: yarn test
release:
needs: test
if: needs.test.outputs.rel == 1 || needs.test.outputs.rel == '1'
permissions:
contents: write
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand Down Expand Up @@ -94,18 +116,11 @@ jobs:
run: yarn
- name: Build code
run: yarn build
# For whatever reason, I have to have a separate secret set to a GitHub PAT to publish
# to GPR -- GITHUB_TOKEN won't work, even if I specify:
#
# permissions:
# packages: write
#
# at the top of the workflow/job.

- name: Set authentication token
run: |
npm set //npm.pkg.github.com/:_authToken ${{ secrets.GPR_AUTH_TOKEN }}
# This step here is a weird workaround to the difference between my NPM and GitHub
# usernames. You can delete it if it's causing trouble or it's unnecessary.
- name: Get ready to publish to GPR
run: |
jq ".name = \"@$REPO\"" package.json > temp.json && mv temp.json package.json
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/issue-welcome.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ permissions:
issues: write
jobs:
welcome-author:
continue-on-error: true
runs-on: ubuntu-latest
steps:
- name: Say hi
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pr-build-failed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
type: string
jobs:
report-pr-build-failed:
continue-on-error: true
permissions:
pull-requests: write
runs-on: ubuntu-latest
Expand Down
35 changes: 27 additions & 8 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,44 @@ jobs:
with:
node-version: 16.x
- name: Clone the main repo
run: cd .. && sudo /usr/bin/git clone https://github.com/${{ github.repository }} main && cd -
- name: Check if the PR is acceptable
run: |
diff -q ./tests/ ../main/tests
diff -q ./.github/ ../main/.github
- name: Copy test suites from main repo to PR
run: cp ../main/tests/*.* tests/
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: Validate package.json
run: yarn validate-package-json
- 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: Report build failed (if any)
if: failure()
uses: ./.github/workflows/pr-build-failed.yml
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pr-welcome.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:

jobs:
say-hi:
continue-on-error: true
permissions:
pull-requests: write
runs-on: ubuntu-latest
Expand Down
14 changes: 2 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
<!-- # Changelog -->
# Changelog

<!--
! This is very important.
! Keep in mind the CI workflow is expecting this file to be structured as shown below
! and to be in sync with the "version" field of your package.json.
## Version 0.0.1

## Version <first version's tag>
- First version!
## Version <next version>
- <a feature introduced in this version>
- <another feature>
...
-->
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

## How to contribute

You can [file an issue](https://github.com/<author>/<repo>/issues)
or a [pull request](https://github.com/<author>/<repo>/pulls).
You can also [start a discussion](https://github.com/<author>/<repo>/discussions).
You can [file an issue](https://github.com/santi100a/queue-lib/issues)
or a [pull request](https://github.com/santi100a/queue-lib/pulls).
You can also [start a discussion](https://github.com/santi100a/queue-lib/discussions).

## Contribution rules

Expand Down
77 changes: 19 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,82 +1,43 @@
# Template for my NPM libraries
# Santi's Quick Queue

Hello, everyone! This is a template repo for my libraries.
You'll find a readme template inside this file.

In order for the CI workflow's publishing jobs to execute successfully, you must have two
Actions secrets set up -- `NPM_AUTH_TOKEN` and `GPR_AUTH_TOKEN`.
They're set to a default dummy value "your-token-here".
You might want to check the [YAML Actions workflow](.github/workflows/main.yml) for hints
and information you may want or need to know.

## Template features

- License (both template contents and code built from it): MIT.
- Code of conduct: adapted from the Contributor Covenant.
- Package manager: Yarn 1.22.19.
- Automatic testing: Jest.
- TypeScript 4.9.5 for built-in type definitions and support for compiling to ES3.
- ESLint and Prettier.
- A pre-commit hook for prettifying and validation, so you don't get embarrased if your PR's CI fails :)
- Security policy and contribution guidelines.

- Self-made scripts for verification of package.json and creation of an ESM wrapper
around TypeScript's CommonJS output to allow for usage within both CJS and ESM projects.

<!-- START README TEMPLATE -->
<!--
* Make sure to replace ALL placeholders.
! The readme will be broken otherwise!
-->

<!-- # Library Name -->
<!-- Badges -->
<!-- Example:
[![Build Status][workflow badge]][repo actions]
[![npm homepage][npm badge]][npm home]
[![GitHub stars][stars badge]][repo url]
[![License][license badge]][repo url]
[![Bundlephobia stats][bundlephobia badge]][bundlephobia url]

[workflow badge]: https://github.com/<author>/<repo>/actions/workflows/main.yml/badge.svg
[npm badge]: https://img.shields.io/npm/v/@<author>/<repo>
[stars badge]: https://img.shields.io/github/stars/<author>/<repo>.svg
[license badge]: https://img.shields.io/github/license/<author>/<repo>.svg
[bundlephobia badge]: https://img.shields.io/bundlephobia/min/@<author>/<repo>
[workflow badge]: https://github.com/santi100a/queue-lib/actions/workflows/ci.yml/badge.svg
[npm badge]: https://img.shields.io/npm/v/@santi100/queue-lib
[stars badge]: https://img.shields.io/github/stars/santi100a/queue-lib.svg
[license badge]: https://img.shields.io/github/license/santi100a/queue-lib.svg
[bundlephobia badge]: https://img.shields.io/bundlephobia/min/@santi100a/queue-lib

[npm home]: https://npmjs.org/package/@<author>/<repo>
[repo actions]: https://github.com/<author>/<repo>/actions
[repo url]: https://github.com/<author>/<repo>
[bundlephobia url]: https://bundlephobia.com/package/@<author>/<repo>@latest
-->
[npm home]: https://npmjs.org/package/@santi100/queue-lib
[repo actions]: https://github.com/santi100a/queue-lib/actions
[repo url]: https://github.com/santi100a/queue-lib
[bundlephobia url]: https://bundlephobia.com/package/@santi100/queue-lib@latest

<!-- Bullet points -->
<!-- Example:
- 🚀 Lightweight and fast[^](#disclaimers)
- 👴 ES3-compliant[*](#disclaimers)
- 💻 Portable between the browser and Node.js
-->
- 📘 Comes with built-in TypeScript definitions

<!-- ## What's this? -->
<!-- Description -->
## What's this?

<!-- Mentions, inspirations -->
This is a simple TypeScript implementation of a queue data structure, where the first item put
onto it (enqueued) is the first to be taken out (dequeued).

<!-- ## Installation -->
<!-- Installation steps and/or commands -->
<!-- Example:
- Via NPM: `npm install @<author>/<repo>`
- Via Yarn: `yarn add @<author>/<repo>`
- Via PNPM: `pnpm install @<author>/<repo>`
-->
- Via NPM: `npm install @santi100/queue-lib`
- Via Yarn: `yarn add @santi100/queue-lib`
- Via PNPM: `pnpm install @santi100/queue-lib`

<!-- ## API -->
## API
<!--
* If a class/function/variable is deprecated, you must cross it out by wrapping the
* `<class/function/variable prototype/definition/type def>;` with tildes, like this:
* ~~`<class/function/variable prototype/definition/type def>;`~~ (deprecated [since <version>])
- `<class/function/variable prototype/definition/type def>;` ([since <version if not first version>]) ([deprecated [since <version>]]) <description>
- `class Queue<T = unknown>;` Main class.
| Name | Type | Description | Optional? | Default |
|------------|-------------|--------------------|-----------|----------------------------------------|
|<param name>|<param type> |<param description> | <Yes/No> | <N/A if not optional, else the default>|
Expand Down
Loading

0 comments on commit 523f7d3

Please sign in to comment.