Skip to content

Commit

Permalink
fix: improve testing
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangsibecas committed Sep 8, 2024
1 parent 99107eb commit 4b6e1e6
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 49 deletions.
36 changes: 36 additions & 0 deletions src/generators/init/generator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,35 @@ describe('init generator', () => {
beforeEach(() => {
tree = createTreeWithEmptyWorkspace();
tree.write('.gitignore', '');
tree.write(
'.github/workflows/ci.yml',
`
name: CI
on:
push:
branches:
- main
pull_request:
permissions:
actions: read
contents: read
jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/action-setup@v4
with:
version: 8
`,
);
});

it('should add plugin to nx.json', async () => {
Expand All @@ -35,4 +64,11 @@ describe('init generator', () => {

expect(gitIgnore.includes('# Foundry')).toBe(true);
});

it('should add github actions step', async () => {
await initGenerator(tree);
expect(tree.read('.github/workflows/ci.yml', 'utf8')).toContain(
'Install Foundry',
);
});
});
49 changes: 0 additions & 49 deletions src/utils/add-github-action-ci.spec.ts

This file was deleted.

4 changes: 4 additions & 0 deletions src/utils/add-github-action-ci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export const addGithubActionCI = async (host: Tree) => {

const file = (await yaml.load(host.read(CI_FILE_PATH, 'utf8'))) as YamlFile;

if (!file.jobs.main.steps) {
return;
}

const actionStep = file.jobs.main.steps.findIndex(
({ uses }) => uses === 'actions/checkout@v4',
);
Expand Down

0 comments on commit 4b6e1e6

Please sign in to comment.