Skip to content

Commit

Permalink
feat(repo): enable semantic-release
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentEnder committed Apr 26, 2021
1 parent e5b1ac5 commit 12c223b
Show file tree
Hide file tree
Showing 12 changed files with 2,562 additions and 71 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [master]
pull_request:
branches: [master]

env:
NX_BRANCH: ${{ github.event.number }}
Expand Down
60 changes: 60 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Run PR checks

on:
# Triggers the workflow on push or pull request events but only for the master branch
pull_request:
branches: [master]

env:
NX_BRANCH: ${{ github.event.number }}
NX_RUN_GROUP: ${{ github.run_id }}

jobs:

build:
runs-on: ubuntu-latest
name: Building affected apps
steps:
- uses: actions/checkout@v1
- uses: bahmutov/npm-install@v1.4.5
- run: yarn nx affected -- --target=build --base=origin/master --parallel --with-deps

test:
runs-on: ubuntu-latest
name: Testing affected apps
steps:
- uses: actions/checkout@v1
- uses: bahmutov/npm-install@v1.4.5
- run: yarn nx affected -- --target=test --base=origin/master --parallel

lint:
runs-on: ubuntu-latest
name: Linting affected apps
steps:
- uses: actions/checkout@v1
- uses: bahmutov/npm-install@v1.4.5
- run: yarn nx affected -- --target=lint --base=origin/master --parallel

commitlint:
runs-on: ubuntu-latest
name: Check commit message for consistency
steps:
- uses: actions/checkout@v1
- uses: bahmutov/npm-install@v1.4.5
- run: yarn commitlint --from origin/master --to HEAD --verbose


# e2e:
# runs-on: ubuntu-latest
# name: E2E testing affected apps
# needs: [pre-run, build]
# if: needs.pre-run.outputs.skip == 'false'
# steps:
# - uses: actions/checkout@v1
# - uses: bahmutov/npm-install@v1.4.5
# - name: Download a single artifact
# uses: actions/download-artifact@v2
# with:
# name: dist
# path: dist
# - run: yarn e2e
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn commitlint --edit "$1"
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn lint-staged
8 changes: 8 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const Configuration = {
extends: ['@commitlint/config-conventional'],
rules: {
'scope-enum': [1, 'always', ['repo', 'dotnet', 'core', 'typescript']],
},
};

module.exports = Configuration;
22 changes: 20 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"build": "nx build",
"test": "nx test",
"lint": "nx workspace-lint && nx lint",
"prepare": "husky install",
"lint-staged": "lint-staged",
"affected:apps": "nx affected:apps",
"affected:libs": "nx affected:libs",
"affected:build": "nx affected:build",
Expand All @@ -26,7 +28,8 @@
"publish-dev": "ts-node tools/scripts/publish-dev",
"e2e-registry": "yarn verdaccio --config ./tools/scripts/local-registry/config.yml --listen 4872",
"e2e-tests": "ts-node -P ./tools/scripts/tsconfig.e2e.json ./tools/scripts/e2e.ts",
"e2e": "run-p -r e2e-registry \"e2e-tests {@}\" --"
"e2e": "run-p -r e2e-registry \"e2e-tests {@}\" --",
"semantic-release": "semantic-release"
},
"private": false,
"dependencies": {
Expand All @@ -38,6 +41,9 @@
"xmldoc": "^1.1.2"
},
"devDependencies": {
"@commitlint/cli": "^12.1.1",
"@commitlint/config-conventional": "^12.1.1",
"@commitlint/types": "^12.1.1",
"@nrwl/cli": "12.0.8",
"@nrwl/devkit": "12.0.8",
"@nrwl/eslint-plugin-nx": "12.0.8",
Expand All @@ -56,13 +62,25 @@
"dotenv": "8.2.0",
"eslint": "7.22.0",
"eslint-config-prettier": "8.1.0",
"husky": "^6.0.0",
"jest": "26.2.2",
"lint-staged": "^10.5.4",
"prettier": "2.2.1",
"run-p": "*",
"semantic-release": "^17.4.2",
"ts-jest": "26.4.0",
"ts-node": "~9.1.1",
"tslib": "^2.0.0",
"typescript": "4.1.4",
"verdaccio": "^5.0.1"
},
"lint-staged": {
"**/*.{js,ts,md,json}": [
"prettier --write"
]
},
"repository": {
"type": "git",
"url": "https://github.com/nx-dotnet/nx-dotnet.git"
}
}
}
4 changes: 2 additions & 2 deletions packages/core/src/executors/test/executor.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TestExecutorSchema } from './schema';
import executor from './executor';
import { TestExecutorSchema } from './schema';

const options: TestExecutorSchema = {};

Expand All @@ -8,4 +8,4 @@ describe('Test Executor', () => {
const output = await executor(options);
expect(output.success).toBe(true);
});
});
});
9 changes: 7 additions & 2 deletions packages/core/src/generators/app/generator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing';

import { DotNetClient, mockDotnetFactory } from '@nx-dotnet/dotnet';

import * as mockedProjectGenerator from '../utils/generate-project';
import generator from './generator';
import { NxDotnetGeneratorSchema } from './schema';
import * as mockedProjectGenerator from '../utils/generate-project';

jest.mock('../utils/generate-project');

Expand Down Expand Up @@ -36,6 +36,11 @@ describe('nx-dotnet library generator', () => {
>).GenerateProject;

await generator(appTree, options, dotnetClient);
expect(projectGenerator).toHaveBeenCalledWith(appTree, options, dotnetClient, 'application');
expect(projectGenerator).toHaveBeenCalledWith(
appTree,
options,
dotnetClient,
'application'
);
});
});
9 changes: 7 additions & 2 deletions packages/core/src/generators/lib/generator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing';

import { DotNetClient, mockDotnetFactory } from '@nx-dotnet/dotnet';

import * as mockedProjectGenerator from '../utils/generate-project';
import generator from './generator';
import { NxDotnetGeneratorSchema } from './schema';
import * as mockedProjectGenerator from '../utils/generate-project';

jest.mock('../utils/generate-project');

Expand Down Expand Up @@ -36,6 +36,11 @@ describe('nx-dotnet library generator', () => {
>).GenerateProject;

await generator(appTree, options, dotnetClient);
expect(projectGenerator).toHaveBeenCalledWith(appTree, options, dotnetClient, 'library');
expect(projectGenerator).toHaveBeenCalledWith(
appTree,
options,
dotnetClient,
'library'
);
});
});
11 changes: 7 additions & 4 deletions packages/core/src/generators/utils/generate-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import {
Tree,
} from '@nrwl/devkit';

import { DotNetClient, dotnetNewOptions } from '@nx-dotnet/dotnet';
import { findProjectFileInPath, isDryRun } from '@nx-dotnet/utils';
import { readFileSync, writeFileSync } from 'fs';
import { dirname, relative } from 'path';
import { XmlDocument, XmlNode, XmlTextNode } from 'xmldoc';
import { relative, dirname } from 'path';

import { DotNetClient, dotnetNewOptions } from '@nx-dotnet/dotnet';
import { findProjectFileInPath, isDryRun } from '@nx-dotnet/utils';

import {
GetBuildExecutorConfiguration,
Expand Down Expand Up @@ -56,7 +57,9 @@ function normalizeOptions(
: [];

const npmScope = names(readWorkspaceConfiguration(host).npmScope).className;
const featureScope = projectDirectory.split('/').map(part => names(part).className);
const featureScope = projectDirectory
.split('/')
.map((part) => names(part).className);
const namespaceName = [npmScope, ...featureScope].join('.');

return {
Expand Down
Loading

0 comments on commit 12c223b

Please sign in to comment.