Skip to content

Commit a4db2a2

Browse files
committed
Merge branch 'release/1.0.8'
2 parents 4c53b44 + 1b666ae commit a4db2a2

File tree

9 files changed

+1985
-81
lines changed

9 files changed

+1985
-81
lines changed

.github/workflows/build.yml

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,75 @@ jobs:
6565
restore-keys: |
6666
${{ runner.os }}-pnpm-store-
6767
68-
- name: Install project dependencies
69-
run: pnpm install # Install all project dependencies.
68+
# Installs all dependencies specified in the project's package.json file.
69+
- name: Install dependencies using pnpm
70+
run: pnpm install
7071

71-
- name: Build & export the App
72-
run: pnpm run build # Builds the app and exports it.
72+
# This compiles the application in optimized production mode and output it to the build folder.
73+
- name: Build the application and export it
74+
run: pnpm run build
75+
76+
# Runs unit tests for the application using Jest.
77+
- name: Execute tests using Jest
78+
run: pnpm run test
79+
80+
release:
81+
# Specify the type of the runner the job will run on
82+
runs-on: ubuntu-latest
83+
84+
needs: [build]
85+
86+
if: ${{ github.ref_name == 'master' }}
87+
88+
# Set permissions to write contents
89+
permissions:
90+
contents: write
91+
92+
steps:
93+
# Checkout the repository code
94+
- name: Checkout code
95+
uses: actions/[email protected]
96+
with:
97+
fetch-depth: 0 # Fetches all history for all branches and tags
98+
99+
# Generate a changelog for the new release using Git
100+
- name: Generate a changelog
101+
uses: orhun/[email protected]
102+
id: git-cliff
103+
with:
104+
config: cliff.toml # The configuration file for git-cliff
105+
args: -vv --latest --strip all # Show verbose output, grab the latest changes, and strip unnecessary details
106+
env:
107+
OUTPUT: CHANGES.md # The output file for the changelog
108+
109+
# Prepare release notes by processing the generated changelog
110+
- name: Set the release info
111+
id: release
112+
shell: bash
113+
run: |
114+
version=$(jq -r '.version' package.json)
115+
echo "version=${version}" >> $GITHUB_OUTPUT
116+
117+
# Read contents of changelog into variable 'changelog_content'
118+
changelog=$(cat ${{ steps.git-cliff.outputs.changelog }})
119+
# Remove first two lines from 'changelog'
120+
changelog="$(printf "$changelog" | tail -n +3)"
121+
# Save the value of 'changelog' back into the GitHub environment output
122+
{
123+
echo "notes<<EOF"
124+
echo "$changelog"
125+
echo "EOF"
126+
} >> $GITHUB_OUTPUT
127+
128+
# Create a new GitHub release using the gathered information
129+
- name: Create the release
130+
uses: nekofar/[email protected]
131+
with:
132+
tag: ${{ steps.release.outputs.version }} # The name of the tag to be released
133+
title: ${{ steps.release.outputs.version }} # The title for the release
134+
notes: ${{ steps.release.outputs.notes }} # The release notes generated in the previous step
135+
draft: true # The release will be created as a draft
136+
prerelease: ${{ contains(steps.release.outputs.version, '-rc') || contains(steps.release.outputs.version, '-beta') || contains(steps.release.outputs.version, '-alpha') }} # Conditions to mark the release as a pre-release
73137

74138
concurrency: # Allows controlling the concurrency level of the job in the build pipeline.
75139
group: ${{ github.workflow }}-${{ github.ref }}

.github/workflows/release.yml

Lines changed: 0 additions & 61 deletions
This file was deleted.

.github/workflows/template.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name: Template Cleanup
44
# Trigger the workflow on push events to the master branch
55
on:
66
push:
7-
branches: [ master ]
7+
branches: [master]
88

99
# Define jobs
1010
jobs:
@@ -28,7 +28,7 @@ jobs:
2828
- name: Set up Node.js environment
2929
uses: actions/[email protected]
3030

31-
- name: Install pnpm package manager # Install pnpm
31+
- name: Install pnpm package manager # Install pnpm
3232
uses: pnpm/[email protected]
3333
with:
3434
version: ^8
@@ -39,12 +39,12 @@ jobs:
3939
# Declare variables
4040
NAME="$(basename $GITHUB_REPOSITORY)"
4141
VERSION='1.0.0-alpha.0'
42-
42+
4343
# Replace package.json name and version fields
4444
pnpm json -I -f package.json -e "this.name='${NAME}'"
4545
pnpm json -I -f package.json -e "this.version='${VERSION}'"
4646
pnpm install --no-frozen-lockfile # Install dependencies (ignoring lock file)
47-
47+
4848
# Remove unnecessary files
4949
rm -rf \
5050
.github/ISSUE_TEMPLATE \
@@ -55,7 +55,7 @@ jobs:
5555
CHANGELOG.md
5656
README.md
5757
58-
- name: Create Pull Request # Generate a pull request
58+
- name: Create Pull Request # Generate a pull request
5959
uses: peter-evans/[email protected]
6060
with:
61-
commit-message: "chore: initial template cleanup" # Commit message
61+
commit-message: 'chore: initial template cleanup' # Commit message

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,6 @@ next-env.d.ts
3939
**/locales/*/*.js
4040
**/locales/*/*.json
4141
**/locales/*/*.mo
42+
43+
# swc
44+
.swc

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,25 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [1.0.8] - 2023-07-30
6+
7+
### <!-- 03 -->Testing
8+
9+
- Add tests for the Home page component
10+
11+
### <!-- 07 -->Continuous Integrations
12+
13+
- Refactor format and readability in `template` workflow
14+
- Update build workflow steps and comments
15+
- Merge release and build workflows
16+
17+
### <!-- 08 -->Miscellaneous Tasks
18+
19+
- Add testing dependencies and plugins
20+
- Add `.swc` files to `.gitignore`
21+
- Add `jest.config.js` for test configuration
22+
- Add Jest testing script to `package.json`
23+
524
## [1.0.7] - 2023-07-29
625

726
### <!-- 07 -->Continuous Integrations

jest.config.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const nextJest = require('next/jest')
2+
3+
const createJestConfig = nextJest({
4+
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
5+
dir: './',
6+
})
7+
8+
// Add any custom config to be passed to Jest
9+
/** @type {import('jest').Config} */
10+
const config = {
11+
// Add more setup options before each test is run
12+
// setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
13+
14+
testEnvironment: 'jest-environment-jsdom',
15+
16+
moduleNameMapper: {
17+
'^@/(.*)$': '<rootDir>/src/$1',
18+
},
19+
}
20+
21+
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
22+
module.exports = createJestConfig(config)

package.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"lint": "next lint",
1212
"lingui:extract": "lingui extract --clean",
1313
"lingui:compile": "lingui compile",
14-
"format": "prettier --log-level error --write ."
14+
"format": "prettier --log-level error --write .",
15+
"test": "jest"
1516
},
1617
"dependencies": {
1718
"@headlessui/react": "1.7.16",
@@ -31,14 +32,21 @@
3132
"@lingui/loader": "4.3.0",
3233
"@lingui/macro": "4.3.0",
3334
"@lingui/swc-plugin": "4.0.4",
35+
"@testing-library/jest-dom": "5.16.5",
36+
"@testing-library/react": "14.0.0",
37+
"@testing-library/user-event": "14.4.3",
38+
"@types/jest": "29.5.0",
3439
"@types/langs": "2.0.1",
3540
"@types/node": "20.4.5",
3641
"@types/react": "18.2.17",
3742
"@types/react-dom": "18.2.7",
43+
"@types/testing-library__jest-dom": "5.14.5",
3844
"autoprefixer": "10.4.14",
3945
"eslint": "8.46.0",
4046
"eslint-config-next": "13.4.12",
4147
"eslint-config-prettier": "8.9.0",
48+
"jest": "29.5.0",
49+
"jest-environment-jsdom": "29.5.0",
4250
"postcss": "8.4.27",
4351
"prettier": "3.0.0",
4452
"prettier-plugin-organize-imports": "3.2.3",

0 commit comments

Comments
 (0)