Skip to content

Commit 36de847

Browse files
author
williamd5
authored
Merge pull request #14 from cloudnode-pro/build-test
Test whether the project builds successfully
2 parents 3e0429f + d8bd272 commit 36de847

File tree

4 files changed

+44
-2
lines changed

4 files changed

+44
-2
lines changed

.github/workflows/test.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Test
2+
'on':
3+
pull_request:
4+
types: [ opened, synchronize, reopened ]
5+
push:
6+
branches:
7+
- 'main'
8+
jobs:
9+
test:
10+
name: 'Build with Node.js v${{ matrix.node }}'
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
node:
15+
- 18
16+
- 16
17+
steps:
18+
- uses: actions/setup-node@v1
19+
with:
20+
node-version: '${{ matrix.node }}'
21+
- uses: actions/checkout@v2
22+
- name: 'Cache node_modules'
23+
uses: actions/cache@v2
24+
with:
25+
path: ~/.npm
26+
key: ${{ runner.os }}-node-v${{ matrix.node }}-${{ hashFiles('**/package.json') }}
27+
restore-keys: |
28+
${{ runner.os }}-node-v${{ matrix.node }}-
29+
- name: Install Dependencies
30+
run: npm install
31+
- name: Build
32+
run: npm run build

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
![Client Version: 1.5.0](https://img.shields.io/badge/Client%20Version-1.5.0-%2316a34a)
44
![API Version: 5.7.1](https://img.shields.io/badge/API%20Version-5.7.1-%232563eb)
5+
![build: passing](https://img.shields.io/badge/build-passing-%2316a34a)
56

67
A client SDK for the Cloudnode API, written in TypeScript. [Documentation](https://github.com/cloudnode-pro/ts-client#documentation)
78

README.template.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
{{{shield.version}}}
44
{{{shield.apiVersion}}}
5+
{{{shield.build}}}
56

67
{{pkg.description}}
78

gen/docs.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import DocSchema from "./DocSchema.js";
55
import fs from "node:fs/promises";
66
import Package from "./Package";
77
import Mustache from "mustache";
8+
import * as child_process from "child_process";
89

910
/**
1011
* Generate doc schema
@@ -92,10 +93,17 @@ export function generateMarkdownDocs (schema: DocSchema, tableOfContents: boolea
9293
*/
9394
export async function generateReadme (docMD: string, config: Config, pkg: Package): Promise<void> {
9495
const template = await fs.readFile("README.template.md", "utf8");
96+
// check if project builds successfully
97+
const buildStatus = await new Promise((resolve, reject) => {
98+
child_process.exec("npm run build", (error, stdout, stderr) => {
99+
resolve(!error);
100+
});
101+
});
95102
const shield = {
96103
version: `![Client Version: ${pkg.version}](https://img.shields.io/badge/Client%20Version-${pkg.version}-%2316a34a)`,
97-
apiVersion: `![API Version: ${config.apiVersion}](https://img.shields.io/badge/API%20Version-${config.apiVersion}-%232563eb)`
98-
}
104+
apiVersion: `![API Version: ${config.apiVersion}](https://img.shields.io/badge/API%20Version-${config.apiVersion}-%232563eb)`,
105+
build: `![build: ${buildStatus ? "passing" : "failing"}](https://img.shields.io/badge/build-${buildStatus ? "passing" : "failing"}-%23${buildStatus ? "16a34a" : "dc2626"})`
106+
};
99107
const rendered = Mustache.render(template, {config, pkg, docMD, shield});
100108
await fs.writeFile("README.md", rendered);
101109
}

0 commit comments

Comments
 (0)