Skip to content

Commit

Permalink
build: remove Docker for building binaries (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyubisation authored May 12, 2024
1 parent c833c50 commit 5ad778f
Show file tree
Hide file tree
Showing 30 changed files with 249 additions and 311 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: Continuous Integration
on: [push, pull_request]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

permissions: read-all

jobs:
lint:
runs-on: ubuntu-latest
Expand All @@ -17,6 +23,7 @@ jobs:

build-and-test-library:
runs-on: ubuntu-latest
needs: lint
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
Expand All @@ -33,8 +40,14 @@ jobs:

build-and-test-cli:
runs-on: ubuntu-latest
needs: lint
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
cache: yarn
node-version-file: '.nvmrc'
- run: yarn install --frozen-lockfile --non-interactive
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
Expand Down
14 changes: 11 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ on:
jobs:
release-cli:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
cache: yarn
node-version-file: '.nvmrc'
- run: yarn install --frozen-lockfile --non-interactive
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
Expand All @@ -21,7 +28,7 @@ jobs:
- uses: actions/github-script@v6
with:
script: |
const fs = require('fs').promises;
const fs = require('fs');
const { owner, repo } = context.repo;
const tagName = context.ref.split('/')[2];
Expand All @@ -34,20 +41,21 @@ jobs:
draft: true,
});
for (const file of await fs.readdir('./dist/cli')) {
for (const file of fs.readdirSync('./dist/cli')) {
console.log(`Adding asset ${file}`);
await github.rest.repos.uploadReleaseAsset({
owner,
repo,
release_id: release.data.id,
name: file,
data: await fs.readFile(`./dist/cli/${file}`),
data: await fs.readFileSync(`./dist/cli/${file}`),
});
}
release-library:
runs-on: ubuntu-latest
needs: release-cli
permissions: read-all
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
Expand Down
5 changes: 2 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ All notable changes to this project will be documented in this file. See [standa

### [17.0.3](https://github.com/kyubisation/angular-server-side-configuration/compare/v17.0.2...v17.0.3) (2024-05-11)


### Bug Fixes

* support object outputPath for Angular application builder ([#96](https://github.com/kyubisation/angular-server-side-configuration/issues/96)) ([6002f8a](https://github.com/kyubisation/angular-server-side-configuration/commit/6002f8a6433166e0c6ff9bc3b01deb85811ac265))
* upgrade golang version and npm dependencies to reduce CVE ([#95](https://github.com/kyubisation/angular-server-side-configuration/issues/95)) ([0989712](https://github.com/kyubisation/angular-server-side-configuration/commit/0989712c8b68df717ce9aa2d4e5604703039ad50))
- support object outputPath for Angular application builder ([#96](https://github.com/kyubisation/angular-server-side-configuration/issues/96)) ([6002f8a](https://github.com/kyubisation/angular-server-side-configuration/commit/6002f8a6433166e0c6ff9bc3b01deb85811ac265))
- upgrade golang version and npm dependencies to reduce CVE ([#95](https://github.com/kyubisation/angular-server-side-configuration/issues/95)) ([0989712](https://github.com/kyubisation/angular-server-side-configuration/commit/0989712c8b68df717ce9aa2d4e5604703039ad50))

### [17.0.2](https://github.com/kyubisation/angular-server-side-configuration/compare/v17.0.1...v17.0.2) (2023-11-12)

Expand Down
43 changes: 17 additions & 26 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"builder": "@angular-devkit/build-angular:application",
"options": {
"outputPath": "dist/ngssc-app",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"browser": "src/main.ts",
"polyfills": ["zone.js"],
"tsConfig": "tsconfig.app.json",
"assets": ["src/favicon.ico", "src/assets"],
"styles": ["src/styles.css"],
Expand All @@ -43,21 +43,18 @@
"maximumError": "4kb"
}
],
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"outputHashing": "all"
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.development.ts"
}
]
}
},
"defaultConfiguration": "production"
Expand Down Expand Up @@ -136,12 +133,12 @@
},
"architect": {
"build": {
"builder": "./dist/angular-server-side-configuration:browser",
"builder": "./dist/angular-server-side-configuration:application",
"options": {
"outputPath": "dist/ngssc-builders-app",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"browser": "src/main.ts",
"polyfills": ["zone.js"],
"tsConfig": "tsconfig.app.json",
"assets": ["src/favicon.ico", "src/assets"],
"styles": ["src/styles.css"],
Expand All @@ -163,23 +160,17 @@
"maximumError": "4kb"
}
],
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"outputHashing": "all"
},
"i18n": {
"outputHashing": "all",
"localize": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
"with": "src/environments/environment.development.ts"
}
],
"outputHashing": "all",
"localize": true
]
},
"development": {
"buildOptimizer": false,
Expand All @@ -191,7 +182,7 @@
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.ngssc.ts"
"with": "src/environments/environment.development.ts"
}
]
}
Expand Down
3 changes: 0 additions & 3 deletions cli/Dockerfile

This file was deleted.

19 changes: 0 additions & 19 deletions docker-compose.yml

This file was deleted.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
"description": "Configure an angular application on the server",
"scripts": {
"build:lib": "node --no-warnings=ExperimentalWarning --loader ts-node/esm/transpile-only ./scripts/build-lib.mts",
"build:cli": "docker-compose run --rm build-go",
"build:cli:upx": "docker-compose run --rm -e BUILD_UPX=true build-go",
"build:cli": "node --no-warnings=ExperimentalWarning --loader ts-node/esm/transpile-only ./scripts/build-cli.mts",
"build:cli:upx": "node --no-warnings=ExperimentalWarning --loader ts-node/esm/transpile-only ./scripts/build-cli.mts upx",
"build:ngssc": "ng run ngssc-app:ngsscbuild:production",
"build:demo": "ng build ngssc-builders-app",
"build:demo-i18n": "ng build ngssc-builders-app -c i18n",
"build:demo": "ng build ngssc-app",
"build:demo-i18n": "ng build ngssc-app -c i18n",
"build": "run-s build:*",
"format": "prettier --write **/*.{js,ts,css,scss,json,md,html}",
"pretest:lib": "yarn -s build:lib",
"test:lib": "node test/jasmine.js",
"test:app": "ng test ngssc-app --configuration=ci",
"test:cli": "cd cli && go test",
"test:cli:coverage": "cd cli && go test -coverprofile=coverage.out && go tool cover -html=coverage.out",
"test:container": "docker-compose up --build local-test",
"test:container": "docker build --tag ngssc-test --file test/Dockerfile.test . && docker run --rm -it -p 8080:8080 ngssc-test",
"test": "run-s test:lib test:app test:cli",
"serve:demo": "cross-env VARIABLE=demo ng serve ngssc-builders-app",
"prepack:lib": "yarn -s build:lib",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,31 @@ import { normalize, virtualFs } from '@angular-devkit/core';

import type { Ngssc } from 'angular-server-side-configuration';

import { applicationHost, createArchitect, legacyHost } from '../../../../test/test-utils';
import {
applicationHost,
browserBuild,
createArchitect,
legacyHost,
} from '../../../../test/test-utils';

describe('Ngssc Builder', () => {
const targetSpec = { project: 'app', target: 'ngsscbuild' };
let architect: Architect | undefined;

async function runNgsscbuild(host: TestProjectHost) {
architect = (await createArchitect(host.root(), host)).architect;

// A "run" can have multiple outputs, and contains progress information.
const run = await architect.scheduleTarget(targetSpec);

// The "result" member (of type BuilderOutput) is the next output.
const output = await run.result;

// Stop the builder from running. This stops Architect from keeping
// the builder-associated states in memory, since builders keep waiting
// to be scheduled.
await run.stop();
return output;
}

function readNgsscJson(host: TestProjectHost, ngsscPath = 'dist/ngssc.json'): Ngssc {
const content = virtualFs.fileBufferToString(host.scopedSync().read(normalize(ngsscPath)));

return JSON.parse(content);
}

describe('@angular-devkit/build-angular:browser', () => {
beforeEach(async () => {
architect = undefined;
await legacyHost.initialize().toPromise();
architect = undefined;
});
afterEach(async () => legacyHost.restore().toPromise());

it('should build with process variant', async () => {
const output = await runNgsscbuild(legacyHost);
architect = (await createArchitect(legacyHost.root(), legacyHost)).architect;
const { output, files } = await browserBuild(architect!, legacyHost, targetSpec);

expect(output.success).toBe(true);

const ngssc = readNgsscJson(legacyHost);
const ngssc = JSON.parse(await files['ngssc.json']);
expect(ngssc.variant).toEqual('process');
expect(ngssc.filePattern).toEqual('index.html');
});
Expand All @@ -56,24 +40,46 @@ describe('Ngssc Builder', () => {
'"additionalEnvironmentVariables": [],',
`"additionalEnvironmentVariables": ["${expected}"],`,
);
const output = await runNgsscbuild(legacyHost);
architect = (await createArchitect(legacyHost.root(), legacyHost)).architect;
const { output, files } = await browserBuild(architect!, legacyHost, targetSpec);

expect(output.success).toBe(true);

const ngssc = readNgsscJson(legacyHost);
const ngssc = JSON.parse(await files['ngssc.json']);
expect(ngssc.environmentVariables).toContain(expected);
});
});

describe('@angular-devkit/build-angular:application', () => {
beforeEach(async () => {
architect = undefined;
await applicationHost.initialize().toPromise();
architect = undefined;
});
afterEach(async () => applicationHost.restore().toPromise());

async function runNgsscbuild() {
architect = (await createArchitect(applicationHost.root(), applicationHost)).architect;

// A "run" can have multiple outputs, and contains progress information.
const run = await architect!.scheduleTarget(targetSpec);

// The "result" member (of type BuilderOutput) is the next output.
const output = await run.result;

// Stop the builder from running. This stops Architect from keeping
// the builder-associated states in memory, since builders keep waiting
// to be scheduled.
await run.stop();
return output;
}

function readNgsscJson(host: TestProjectHost, ngsscPath = 'dist/ngssc.json'): Ngssc {
const content = virtualFs.fileBufferToString(host.scopedSync().read(normalize(ngsscPath)));
return JSON.parse(content);
}

it('should build with process variant', async () => {
const output = await runNgsscbuild(applicationHost);
const output = await runNgsscbuild();

expect(output.success).toBe(true);

Expand All @@ -89,7 +95,7 @@ describe('Ngssc Builder', () => {
'"additionalEnvironmentVariables": [],',
`"additionalEnvironmentVariables": ["${expected}"],`,
);
const output = await runNgsscbuild(applicationHost);
const output = await runNgsscbuild();

expect(output.success).toBe(true);

Expand All @@ -103,7 +109,7 @@ describe('Ngssc Builder', () => {
/("server":\s+"src\/main.server.ts",|"prerender":\s+true,|"ssr":\s+\{\s+"entry":\s+"server.ts"\s+\})/g,
'',
);
const output = await runNgsscbuild(applicationHost);
const output = await runNgsscbuild();

expect(output.success).toBe(true);

Expand All @@ -118,7 +124,7 @@ describe('Ngssc Builder', () => {
'"outputPath": "dist",',
`"outputPath": { "base": "dist", "browser": "html" },`,
);
const output = await runNgsscbuild(applicationHost);
const output = await runNgsscbuild();

expect(output.success).toBe(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export async function ngsscBuild(options: NgsscBuildSchema, context: BuilderCont
if (!result.success) {
const buildConfig = buildTarget.configuration ? `:${buildTarget.configuration}` : '';
context.logger.warn(
`ngssc: Failed build of ${buildTarget.app}:${buildTarget.target}${buildConfig}. Skipping ngssc build.`,
`ngssc: Failed build of ${buildTarget.project}:${buildTarget.target}${buildConfig}. Skipping ngssc build.`,
);
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
"factory": "./ng-update/index#dockerfile"
}
}
}
}
Loading

0 comments on commit 5ad778f

Please sign in to comment.