Skip to content

Commit

Permalink
Fix/actions is not functioning correctly (#86)
Browse files Browse the repository at this point in the history
* Fix/pull_request is not working correctly

* Fix/publish.yml is not working correctly

* Chore/update jest config

* pnpm version 8.6.12 -> 8.7.1

* remove echo repo

* add Codecov badge

* 3.5.6
  • Loading branch information
ishiko732 committed Apr 16, 2024
1 parent cf84e67 commit e046b55
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 85 deletions.
85 changes: 85 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: ci

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

on:
workflow_dispatch:
pull_request:
branches:
- main
- master
- dev
paths-ignore:
- ".devcontainer/**"
# - '.github/**'
- ".vscode/**"
- ".gitignore"
- ".npmignore"
- "LICENSE"
- "README.md"
push:
paths-ignore:
- ".devcontainer/**"
# - '.github/**'
- ".vscode/**"
- ".gitignore"
- ".npmignore"
- "LICENSE"
- "README.md"
branches:
- main
- master
- dev

permissions:
contents: read # to fetch code (actions/checkout)

jobs:
build:
strategy:
matrix:
node: [16]
platform: [ubuntu-latest, macos-latest, windows-latest]
name: "${{matrix.platform}} / Node.js ${{ matrix.node }}"
runs-on: ${{matrix.platform}}

steps:
- uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 16
- uses: pnpm/action-setup@v2.2.2
with:
version: 8.7.1

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Lint
run: pnpm run lint

- name: Run tests and collect coverage
run: pnpm run test::coverage

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: ${{ env.GITHUB_REPOSITORY }}
fail_ci_if_error: true
65 changes: 41 additions & 24 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,65 @@
name: Publish Package

on:
release:
types: [ published ]
pull_request:
workflow_run:
workflows: [ci]
types:
- closed
- completed
branches: [main, master]
release:
types: [published]

jobs:

publish-npm:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write # allow GITHUB_TOKEN to publish packages
id-token: write
steps:
- name: Check Pull Request Status
run: |
if [ "${{ github.event.pull_request.merged }}" = "true" ]; then
echo "Pull request merged successfully."
else
echo "Pull request not merged. Skipping further steps."
exit 0
fi
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 16
- uses: pnpm/action-setup@v2.2.2
with:
version: 8.7.1
- run: pnpm install
- run: pnpm lint
- run: pnpm test

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Lint
run: pnpm run lint

- name: Run tests and collect coverage
run: pnpm run test::coverage

- run: pnpm build
- name: Determine Target Branch
id: determine-branch
run: echo "::set-output name=branch::${{ github.event.pull_request.base.ref }}"

- name: Determine Tag
id: determine-tag
run: echo "::set-output name=tag::${{ steps.determine-branch.outputs.branch == 'master' && 'latest' || 'beta' }}"
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: ${{ env.GITHUB_REPOSITORY }}
fail_ci_if_error: true

- name: Publish Package to NPM
uses: JS-DevTools/npm-publish@v2
with:
token: ${{secrets.npm_token}}
provenance: true
tag: ${{ steps.determine-tag.outputs.tag }}
tag: latest
50 changes: 0 additions & 50 deletions .github/workflows/pr-test.yml

This file was deleted.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# About The
[![ts-fsrs npm version](https://img.shields.io/npm/v/ts-fsrs.svg)](https://www.npmjs.com/package/ts-fsrs)
[![Downloads](https://img.shields.io/npm/dm/ts-fsrs)](https://www.npmjs.com/package/ts-fsrs)
[![codecov](https://codecov.io/gh/open-spaced-repetition/ts-fsrs/graph/badge.svg?token=E3KLLDL8QH)](https://codecov.io/gh/open-spaced-repetition/ts-fsrs)
[![Build and Publish](https://github.com/open-spaced-repetition/ts-fsrs/actions/workflows/npm-publish.yml/badge.svg)](https://github.com/open-spaced-repetition/ts-fsrs/actions/workflows/npm-publish.yml)
[![Deploy](https://github.com/open-spaced-repetition/ts-fsrs/actions/workflows/deploy.yml/badge.svg)](https://github.com/open-spaced-repetition/ts-fsrs/actions/workflows/deploy.yml)

Expand Down
1 change: 1 addition & 0 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# 关于

[![ts-fsrs npm version](https://img.shields.io/npm/v/ts-fsrs.svg)](https://www.npmjs.com/package/ts-fsrs)
[![codecov](https://codecov.io/gh/open-spaced-repetition/ts-fsrs/graph/badge.svg?token=E3KLLDL8QH)](https://codecov.io/gh/open-spaced-repetition/ts-fsrs)
[![Build and Publish](https://github.com/open-spaced-repetition/ts-fsrs/actions/workflows/npm-publish.yml/badge.svg)](https://github.com/open-spaced-repetition/ts-fsrs/actions/workflows/npm-publish.yml)
[![Deploy](https://github.com/open-spaced-repetition/ts-fsrs/actions/workflows/deploy.yml/badge.svg)](https://github.com/open-spaced-repetition/ts-fsrs/actions/workflows/deploy.yml)

Expand Down
1 change: 1 addition & 0 deletions README_JP.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# について

[![ts-fsrs npm version](https://img.shields.io/npm/v/ts-fsrs.svg)](https://www.npmjs.com/package/ts-fsrs)
[![codecov](https://codecov.io/gh/open-spaced-repetition/ts-fsrs/graph/badge.svg?token=E3KLLDL8QH)](https://codecov.io/gh/open-spaced-repetition/ts-fsrs)
[![Build and Publish](https://github.com/open-spaced-repetition/ts-fsrs/actions/workflows/npm-publish.yml/badge.svg)](https://github.com/open-spaced-repetition/ts-fsrs/actions/workflows/npm-publish.yml)
[![Deploy](https://github.com/open-spaced-repetition/ts-fsrs/actions/workflows/deploy.yml/badge.svg)](https://github.com/open-spaced-repetition/ts-fsrs/actions/workflows/deploy.yml)

Expand Down
13 changes: 6 additions & 7 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: [
'**/__tests__/*.js?(x)',
'**/__tests__/*.ts?(x)',
],
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
testMatch: ["**/__tests__/*.js?(x)", "**/__tests__/*.ts?(x)"],
collectCoverage: true,
coverageReporters: ["text", "cobertura"],
coverageThreshold: {
global: {
lines: 80,
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ts-fsrs",
"version": "3.5.5",
"version": "3.5.6",
"description": "ts-fsrs is a ES modules package based on TypeScript, used to implement the Free Spaced Repetition Scheduler (FSRS) algorithm. It helps developers apply FSRS to their flashcard applications, there by improving the user learning experience.",
"main": "dist/index.cjs",
"umd": "dist/index.umd.js",
Expand Down Expand Up @@ -41,8 +41,8 @@
"scripts": {
"lint": "eslint --fix src/ && prettier --write src/",
"dev": "rollup -c rollup.config.ts --configPlugin esbuild -w",
"test": "jest --passWithNoTests",
"test:coverage": "jest --coverage",
"test": "jest --config=jest.config.js --passWithNoTests",
"test::coverage": "jest --config=jest.config.js --coverage",
"prebuild": "rimraf ./dist",
"build": "rollup -c rollup.config.ts --configPlugin esbuild",
"build:types": "tsc --project ./tsconfig.json --declaration true",
Expand Down
2 changes: 1 addition & 1 deletion src/fsrs/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const default_w = [
];
export const default_enable_fuzz = false;

export const FSRSVersion: string = "3.5.5";
export const FSRSVersion: string = "3.5.6";

export const generatorParameters = (
props?: Partial<FSRSParameters>,
Expand Down

0 comments on commit e046b55

Please sign in to comment.