Skip to content

Commit

Permalink
chore(ci): add ci.yml for github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
zxf4399 committed Mar 25, 2023
1 parent 36503b5 commit 3b4e131
Show file tree
Hide file tree
Showing 5 changed files with 5,706 additions and 7,909 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: CI

on:
push:
branches:
- main
- release
- 26-add-ci-yml
pull_request:

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: "Setup Node.js"
uses: actions/setup-node@v3
with:
node-version: 18
- name: "Setup pnpm"
uses: pnpm/action-setup@v2
with:
version: 7.26.3

- name: "Get pnpm store directory"
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: "Setup pnpm cache"
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm i

- name: Test
run: pnpm test
24 changes: 14 additions & 10 deletions __tests__/clone.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,28 @@ describe("clone command", () => {
test("The Git user config is set correctly when the Git repository is successfully cloned.", async () => {
await runCloneCommand(MGRE_GIT_REPO_URL)

await execa("cd", [MGRE_REPO_LOCAL_PATH])

const codebase = mgreConfig.get(MGRE_CONIFG_FIELDS.CODEBASES)?.[
"github.com"
]

if (codebase?.name && codebase?.email) {
const { stdout: username } = await execa("git", [
"config",
"user.name",
])
const { stdout: username } = await execa(
"git",
["config", "user.name"],
{
cwd: MGRE_REPO_LOCAL_PATH,
}
)

expect(username).toBe(codebase.name)

const { stdout: useremail } = await execa("git", [
"config",
"user.email",
])
const { stdout: useremail } = await execa(
"git",
["config", "user.email"],
{
cwd: MGRE_REPO_LOCAL_PATH,
}
)

expect(useremail).toBe(codebase.email)
}
Expand Down

0 comments on commit 3b4e131

Please sign in to comment.