Skip to content
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

Align CI task with i18next repo #1727

Merged
merged 2 commits into from
Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
105 changes: 105 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: CI

on:
push:
branches:
- master
pull_request:
# types: [opened, synchronize, reopened, ready_for_review]
branches:
- '**'

jobs:
codeQuality:
name: Check code quality (lint and format)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'

- name: Install dependencies
run: npm install

- name: Format check
run: npm run format

- name: Lint
run: npm run lint

build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'

- name: Install dependencies
run: npm install

- name: Build
run: npm run build

test:
name: Test on node ${{ matrix.node }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
node: [ '20.x', '18.x' ]
os: [ubuntu-latest]
# Collect coverage only for node 20 and ubuntu-latest, no need to run it twice
# @see https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs#expanding-or-adding-matrix-configurations
include:
- collectCoverage: true
node: '20.x'
os: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'npm'

- name: Install dependencies
run: npm install

- name: Test
if: ${{ !matrix.collectCoverage }}
run: npm test

- name: Test with coverage
if: ${{ matrix.collectCoverage }}
run: npm run test:coverage

- name: Coveralls
if: ${{ matrix.collectCoverage }}
uses: coverallsapp/github-action@v2

testTypescript:
name: Test typescript
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'

- name: Install dependencies
run: npm install

- name: Test
run: npm run test:typescript
38 changes: 0 additions & 38 deletions .github/workflows/lint_and_test.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# react-i18next [![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Awesome%20react-i18next%20for%20react.js%20based%20on%20i18next%20internationalization%20ecosystem%20&url=https://github.com/i18next/react-i18next&via=jamuhl&hashtags=i18n,reactjs,js,dev)

[![Lint & Test](https://github.com/i18next/react-i18next/actions/workflows/lint_and_test.yml/badge.svg)](https://github.com/i18next/react-i18next/actions/workflows/lint_and_test.yml)
[![CI](https://github.com/i18next/react-i18next/actions/workflows/CI.yml/badge.svg)](https://github.com/i18next/react-i18next/actions/workflows/CI.yml)
[![Code Climate](https://codeclimate.com/github/codeclimate/codeclimate/badges/gpa.svg)](https://codeclimate.com/github/i18next/react-i18next)
[![Coverage Status](https://coveralls.io/repos/github/i18next/react-i18next/badge.svg)](https://coveralls.io/github/i18next/react-i18next)
[![Quality][quality-badge]][quality-url]
Expand Down
6 changes: 0 additions & 6 deletions example/react_native_windows/.prettierrc.js

This file was deleted.

7 changes: 7 additions & 0 deletions example/react_native_windows/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "https://json.schemastore.org/prettierrc.json",
"bracketSpacing": false,
"bracketSameLine": true,
"singleQuote": true,
"trailingComma": "all"
}
3 changes: 1 addition & 2 deletions example/react_native_windows/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ function Content() {
<SafeAreaView>
<ScrollView
contentInsetAdjustmentBehavior="automatic"
style={styles.scrollView}
>
style={styles.scrollView}>
<View style={styles.body}>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>{t('hello')}</Text>
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@
"scripts": {
"clean": "rimraf dist && mkdirp dist",
"lint": "eslint ./src ./test",
"format": "prettier \"{,**/}*.{ts,tsx,mts,js,json,md}\" --check",
"format:fix": "prettier \"{,**/}*.{ts,tsx,mts,js,json,md}\" --write",
"copy": "cp-cli ./dist/umd/react-i18next.min.js ./react-i18next.min.js && cp-cli ./dist/umd/react-i18next.js ./react-i18next.js && echo '{\"type\":\"module\"}' > dist/es/package.json",
"build:es": "cross-env BABEL_ENV=jsnext babel src --out-dir dist/es",
"build:cjs": "babel src --out-dir dist/commonjs",
Expand All @@ -144,13 +146,11 @@
"fix_dist_package": "node -e 'console.log(`{\"type\":\"module\",\"version\":\"${process.env.npm_package_version}\"}`)' > dist/es/package.json",
"preversion": "npm run build && git push",
"postversion": "npm run fix_dist_package && git push && git push --tags",
"pretest": "npm run lint",
"test": "vitest run --typecheck --workspace vitest.workspace.mts",
"test:runtime": "npm run test -- --project runtime",
"test:coverage": "npm run test:runtime -- --coverage --run",
"test": "vitest",
"test:coverage": "npm run test -- --coverage --run",
"test:typescript": "vitest --workspace vitest.workspace.typescript.mts",
"contributors:add": "all-contributors add",
"contributors:generate": "all-contributors generate",
"prettier": "prettier --write \"{,**/}*.{mts,ts,tsx,js,json,md}\"",
"prepare": "husky install"
},
"author": "Jan Mühlemann <jan.muehlemann@gmail.com> (https://github.com/jamuhl)",
Expand Down
6 changes: 6 additions & 0 deletions vitest.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ import { defineConfig } from 'vitest/config';

export default defineConfig({
test: {
name: 'runtime',
dir: './test',
exclude: ['**/typescript/**'],
environment: 'happy-dom',
setupFiles: ['./test/setup'],

coverage: {
reporter: ['text', 'html', 'json', 'lcov'],
include: ['**/src/*.{js,jsx}', '*.macro.js'],
Expand Down
17 changes: 3 additions & 14 deletions vitest.workspace.mts → vitest.workspace.typescript.mts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,12 @@ import { readdirSync } from 'node:fs';
import { defineWorkspace } from 'vitest/config';
import type { UserProjectConfigExport } from 'vitest/config';

export default defineWorkspace([
{
test: {
name: 'runtime',
dir: './test',
exclude: ['**/typescript/**'],
environment: 'happy-dom',

setupFiles: ['./test/setup'],
},
},

export default defineWorkspace(
/**
* If you need to test multiple typescript configurations (like misc) simply create a file named tsconfig.{customName}.json
* and this script will automatically create a new workspace named with the dirName followed by `customName`
*/
...readdirSync('./test/typescript', { withFileTypes: true })
readdirSync('./test/typescript', { withFileTypes: true })
.filter((dir) => dir.isDirectory())
.reduce<UserProjectConfigExport[]>((workspaces, dir) => {
const dirPath = `test/typescript/${dir.name}` as const;
Expand Down Expand Up @@ -49,4 +38,4 @@ export default defineWorkspace([

return workspaces;
}, []),
]);
);