Skip to content

Commit

Permalink
Optimise build workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
badsyntax committed May 18, 2020
1 parent 0718663 commit 6c05a27
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 65 deletions.
21 changes: 11 additions & 10 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,14 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: 12.16.2
- name: Build Project
uses: eskatos/gradle-command-action@v1
with:
arguments: build
- name: Lint
uses: eskatos/gradle-command-action@v1
with:
arguments: lint
- name: SonarQube Analyse
- name: Build & Analyse
uses: eskatos/gradle-command-action@v1
with:
arguments: sonarqube
arguments: tasks-server:build sonarqube -x :test -x extension:test -x npm-package:test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_SONARCLOUD_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Expand All @@ -49,7 +45,7 @@ jobs:
matrix:
node-version: [12.16.2]
java-version: ['8', '11']
os: [ubuntu-latest, windows-latest, macos-latest]
os: [macos-latest]
steps:
- uses: actions/checkout@v1
- name: Use Node ${{ matrix.node-version }}
Expand All @@ -61,15 +57,19 @@ jobs:
with:
java-version: ${{ matrix.java-version }}
architecture: x64
- name: Build Project
- name: Build Extension
uses: eskatos/gradle-command-action@v1
with:
arguments: build -x test -x serverStartScripts -x compileJava -x shadowJar -x startShadowScripts
arguments: extension:build
- name: Download lib
uses: actions/download-artifact@v1
with:
name: lib
path: extension/lib
- name: MacOS fix
run: |
export NODE_OPTIONS="--no-force-async-hooks-checks"
if: matrix.os == 'macos-latest'
- name: Start Xvfb
run: |
Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
Expand All @@ -82,7 +82,8 @@ jobs:
- name: Test extension
uses: eskatos/gradle-command-action@v1
with:
arguments: testVsCode -x test -x serverStartScripts -x compileJava -x shadowJar -x startShadowScripts
arguments: testVsCode
env:
DISPLAY: ':99.0'
CI: 'true'
NODE_OPTIONS: '--no-force-async-hooks-checks'
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Build & prepare extension
uses: eskatos/gradle-command-action@v1
with:
arguments: extension:prepareForRelease npm-package:build
arguments: prepareForRelease
- name: Publish types
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand Down
16 changes: 8 additions & 8 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceFolder}/extension"],
"outFiles": ["${workspaceFolder}/extension/dist/**/*.js"],
"preLaunchTask": "Gradle: Build TypeScript",
"preLaunchTask": "Gradle: Build",
"presentation": {
"group": "debug",
"order": 1
Expand All @@ -33,7 +33,7 @@
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceFolder}/extension"],
"outFiles": ["${workspaceFolder}/extension/dist/**/*.js"],
"preLaunchTask": "Gradle: Build TypeScript",
"preLaunchTask": "Gradle: Build",
"env": {
"VSCODE_DEBUG_SERVER": "true"
},
Expand All @@ -57,7 +57,7 @@
"${workspaceFolder}/extension/test-fixtures/gradle-groovy-default-build-file"
],
"outFiles": ["${workspaceFolder}/extension/out/test/**/*.js"],
"preLaunchTask": "Gradle: Build TypeScript & Tests",
"preLaunchTask": "Gradle: Build",
"presentation": {
"group": "test"
}
Expand All @@ -78,7 +78,7 @@
"${workspaceFolder}/extension/test-fixtures/gradle-kotlin-default-build-file"
],
"outFiles": ["${workspaceFolder}/extension/out/test/**/*.js"],
"preLaunchTask": "Gradle: Build TypeScript & Tests",
"preLaunchTask": "Gradle: Build",
"presentation": {
"group": "test"
}
Expand All @@ -99,7 +99,7 @@
"${workspaceFolder}/extension/test-fixtures/gradle-groovy-custom-build-file"
],
"outFiles": ["${workspaceFolder}/extension/out/test/**/*.js"],
"preLaunchTask": "Gradle: Build TypeScript & Tests",
"preLaunchTask": "Gradle: Build",
"presentation": {
"group": "test"
}
Expand All @@ -119,7 +119,7 @@
"${workspaceFolder}/extension/test-fixtures/no-gradle"
],
"outFiles": ["${workspaceFolder}/extension/out/test/**/*.js"],
"preLaunchTask": "Gradle: Build TypeScript & Tests",
"preLaunchTask": "Gradle: Build",
"presentation": {
"group": "test"
}
Expand All @@ -140,7 +140,7 @@
"${workspaceFolder}/extension/test-fixtures/multi-root/multiple-project.code-workspace"
],
"outFiles": ["${workspaceFolder}/extension/out/test/**/*.js"],
"preLaunchTask": "Gradle: Build TypeScript & Tests",
"preLaunchTask": "Gradle: Build",
"presentation": {
"group": "test"
}
Expand All @@ -160,7 +160,7 @@
"${workspaceFolder}/extension/test-fixtures/multi-project"
],
"outFiles": ["${workspaceFolder}/extension/out/test/**/*.js"],
"preLaunchTask": "Gradle: Build TypeScript & Tests",
"preLaunchTask": "Gradle: Build",
"presentation": {
"group": "test"
}
Expand Down
27 changes: 2 additions & 25 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,14 @@
"version": "2.0.0",
"tasks": [
{
"label": "Gradle: Build TypeScript",
"label": "Gradle: Build",
"type": "shell",
"problemMatcher": "$tsc-watch",
"command": "./gradlew",
"windows": {
"command": ".\\gradlew.bat"
},
"args": [":extension:buildTypeScript", "-x", "test"],
"isBackground": true,
"presentation": {
"reveal": "always"
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Gradle: Build TypeScript & Tests",
"type": "shell",
"problemMatcher": "$tsc-watch",
"command": "./gradlew",
"windows": {
"command": ".\\gradlew.bat"
},
"args": [
":extension:buildTypeScript",
":extension:buildTypeScriptTests",
"-x",
"test"
],
"args": ["build", "-x", "test"],
"isBackground": true,
"presentation": {
"reveal": "always"
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Open the root of the project in VS Code.

Open the Debug panel, and select one of the `debug` tasks, for example `Debug Extension`, or any of the test launch configurations.

You can also run `./gradlew test testVsCode` to run all tests.
You can also run `./gradlew build testVsCode` to run all tests.

### Code Style

Expand Down
2 changes: 0 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,3 @@ subprojects {
task(format) {
dependsOn(spotlessApply)
}

project.tasks["sonarqube"].dependsOn ':extension:buildTypeScript'
32 changes: 17 additions & 15 deletions extension/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ compileTestJava.enabled = false
processResources.enabled = false;

clean {
dependsOn ':tasks-server:clean'
delete protobuf.generatedFilesBaseDir
delete file('node_modules')
delete file(protoLib)
Expand Down Expand Up @@ -112,7 +111,7 @@ task npmInstall(type: CrossPlatformExec) {
description 'Installs node dependencies'
inputs.file('package-lock.json')
outputs.dir('node_modules')
commandLine 'npm', 'install'
commandLine 'npm', 'ci'
}

task lint(type: CrossPlatformExec) {
Expand All @@ -126,19 +125,19 @@ task format(type: CrossPlatformExec) {
commandLine 'npm', 'run', 'lint:fix'
}

task buildTypeScript(type: CrossPlatformExec) {
dependsOn assemble, ':tasks-server:generateProto', copyProtoJs, copyProtoTs
task buildDev(type: CrossPlatformExec) {
dependsOn copyProtoJs, copyProtoTs
group 'build'
description 'Builds TypeScript source files'
description 'Builds development version TypeScript source files'
outputs.dir('dist')
inputs.dir('src')
inputs.file('webpack.config.js')
inputs.file('tsconfig.json')
commandLine 'npm', 'run', 'compile:dev'
}

task buildTypeScriptTests(type: CrossPlatformExec) {
dependsOn assemble, ':tasks-server:generateProto', copyProtoJs, copyProtoTs
task buildTest(type: CrossPlatformExec) {
dependsOn copyProtoJs, copyProtoTs
group 'build'
description 'Builds TypeScript test source files'
buildDir = 'out'
Expand All @@ -149,24 +148,29 @@ task buildTypeScriptTests(type: CrossPlatformExec) {
commandLine 'npm', 'run', 'compile:test'
}

task bundle(type: CrossPlatformExec) {
dependsOn ':tasks-server:build', ':npm-package:build', copyProtoJs, copyProtoTs
task buildProd(type: CrossPlatformExec) {
dependsOn copyProtoJs, copyProtoTs
group 'build'
description 'Bundles the extension files for release'
description 'Builds production version TypeScript source files'
buildDir = 'dist'
outputs.dir("$buildDir")
inputs.dir('src')
inputs.file('webpack.config.js')
commandLine 'npm', 'run', 'compile:prod'
}

task bundle() {
dependsOn buildProd, ':npm-package:build'
group 'build'
description 'Bundles the extension files for release'
}

task installExtension(type: CrossPlatformExec) {
dependsOn bundle
commandLine 'npm', 'run', 'install:ext'
}

task testVsCode(type: CrossPlatformExec) {
dependsOn copyProtoJs, copyProtoTs
group 'verification'
description 'Tests the extension'
commandLine 'npm', 'run', 'test'
Expand All @@ -180,9 +184,7 @@ task copyDocs(type: Copy) {
}

task prepareForRelease() {
dependsOn build, bundle, copyDocs
dependsOn bundle, copyDocs
}

build.dependsOn ':tasks-server:build'
assemble.dependsOn ':tasks-server:build'
assemble.finalizedBy buildTypeScript, buildTypeScriptTests
build.finalizedBy buildDev, buildTest
1 change: 1 addition & 0 deletions extension/src/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ export class GradleTaskProvider
*/): Promise<
vscode.Task | undefined
> {
console.log('TRYING TO RESOLVE TASK');
return undefined;
}

Expand Down
2 changes: 2 additions & 0 deletions extension/src/test/gradle/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,12 @@ describe(fixtureName, () => {
const task = (await vscode.tasks.fetchTasks({ type: 'gradle' })).find(
({ name }) => name === 'helloProjectProperty'
);
console.log('got task', JSON.stringify(task, null, 2));
assert.ok(task);
const spy = sinon.spy(extension.exports.logger, 'append');
const treeDataProvider = extension?.exports
.treeDataProvider as GradleTasksTreeDataProvider;
console.log('got treeData Provider', treeDataProvider);
await new Promise((resolve) => {
// eslint-disable-next-line sonarjs/no-identical-functions
vscode.tasks.onDidEndTaskProcess((e) => {
Expand Down
6 changes: 3 additions & 3 deletions npm-package/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ task copyProtoLib(type: Copy) {
}

task copyPublicApi(type: Copy) {
dependsOn ':extension:buildTypeScript'
dependsOn ':extension:buildProd'
group 'copy'
description 'Copies publc API types'
from file("../extension/out")
Expand All @@ -34,7 +34,7 @@ task npmInstall(type: CrossPlatformExec) {
description 'Installs node dependencies'
inputs.file('package-lock.json')
outputs.dir('node_modules')
commandLine 'npm', 'install'
commandLine 'npm', 'ci'
}

task compileTypeScript(type: CrossPlatformExec) {
Expand All @@ -46,7 +46,7 @@ task compileTypeScript(type: CrossPlatformExec) {
commandLine 'npm', 'run', 'compile'
}

assemble.finalizedBy npmInstall,
build.finalizedBy npmInstall,
compileTypeScript,
copyProtoLib,
copyPublicApi
1 change: 1 addition & 0 deletions tasks-server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,5 @@ task(format) {
dependsOn(spotlessApply)
}

compileJava.dependsOn 'generateProto'
assemble.dependsOn serverStartScripts

0 comments on commit 6c05a27

Please sign in to comment.