diff --git a/.eslintrc.json b/.eslintrc.json index fa18cbc..c29058b 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -21,5 +21,7 @@ "eslint-plugin-jest" ], "rules": { + "@typescript-eslint/no-var-requires": "off", + "no-console": "warn" } } diff --git a/.github/workflows/check-md-links.yml b/.github/workflows/check-md-links.yml new file mode 100644 index 0000000..87a2e30 --- /dev/null +++ b/.github/workflows/check-md-links.yml @@ -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 diff --git a/.github/workflows/main.yml b/.github/workflows/ci.yml similarity index 80% rename from .github/workflows/main.yml rename to .github/workflows/ci.yml index 9595708..66582b5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/ci.yml @@ -9,6 +9,8 @@ on: jobs: test: + outputs: + rel: ${{ steps.commit.outputs.rel }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -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 @@ -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 @@ -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 diff --git a/.github/workflows/issue-welcome.yml b/.github/workflows/issue-welcome.yml index af503b9..5e1b190 100644 --- a/.github/workflows/issue-welcome.yml +++ b/.github/workflows/issue-welcome.yml @@ -7,6 +7,7 @@ permissions: issues: write jobs: welcome-author: + continue-on-error: true runs-on: ubuntu-latest steps: - name: Say hi diff --git a/.github/workflows/pr-build-failed.yml b/.github/workflows/pr-build-failed.yml index 017cea7..73e691a 100644 --- a/.github/workflows/pr-build-failed.yml +++ b/.github/workflows/pr-build-failed.yml @@ -10,6 +10,7 @@ on: type: string jobs: report-pr-build-failed: + continue-on-error: true permissions: pull-requests: write runs-on: ubuntu-latest diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index 24d9fca..749e2de 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -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 diff --git a/.github/workflows/pr-welcome.yml b/.github/workflows/pr-welcome.yml index 9bfb887..06eb478 100644 --- a/.github/workflows/pr-welcome.yml +++ b/.github/workflows/pr-welcome.yml @@ -6,6 +6,7 @@ on: jobs: say-hi: + continue-on-error: true permissions: pull-requests: write runs-on: ubuntu-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index 17017d3..20efb01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,15 +1,5 @@ - +# Changelog - \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8c4fb17..f527bde 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,9 +2,9 @@ ## How to contribute -You can [file an issue](https://github.com///issues) -or a [pull request](https://github.com///pulls). -You can also [start a discussion](https://github.com///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 diff --git a/README.md b/README.md index a800453..3e7caa8 100644 --- a/README.md +++ b/README.md @@ -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. - - - - - - - +[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 - - +- 📘 Comes with built-in TypeScript definitions - - +## What's this? - +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). - - - +- Via NPM: `npm install @santi100/queue-lib` +- Via Yarn: `yarn add @santi100/queue-lib` +- Via PNPM: `pnpm install @santi100/queue-lib` - +## API