Skip to content

Commit

Permalink
add CI
Browse files Browse the repository at this point in the history
  • Loading branch information
bodinsamuel committed Apr 28, 2023
1 parent 59c7529 commit 541e8ba
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 57 deletions.
33 changes: 33 additions & 0 deletions .github/worfkflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Main
on:
push:
branches: [ main ]
pull_request:
types: [opened, synchronize]

jobs:
ci:
container: node:18.13.0
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- name: Check out repository code
uses: actions/checkout@v3

- name: Install Node
uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
cache: 'npm'
cache-dependency-path: |
package-lock.json
- name: Install dependencies
run: npm ci

- name: Lint
run: npm run lint

- name: Run Test API
run: npm run test
95 changes: 48 additions & 47 deletions src/analyser/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe('techAnalyser', () => {
}),
});

// console.log(res.toJson());
expect(res.toJson()).toStrictEqual({
id: expect.any(String),
name: 'main',
Expand All @@ -24,17 +25,6 @@ describe('techAnalyser', () => {
inComponent: null,
edges: [],
components: [
{
id: expect.any(String),
name: 'db',
group: 'component',
edges: [],
languages: {},
path: '/docker-compose.yml',
tech: 'postgresql',
techs: [],
inComponent: null,
},
{
id: expect.any(String),
name: 'api',
Expand All @@ -52,17 +42,6 @@ describe('techAnalyser', () => {
},
techs: ['fastify', 'nodejs', 'prisma', 'typescript'],
},
{
id: expect.any(String),
name: 'vercel',
group: 'hosting',
languages: {},
edges: [],
path: '',
tech: 'vercel',
inComponent: null,
techs: [],
},
{
id: expect.any(String),
name: 'app',
Expand All @@ -89,32 +68,14 @@ describe('techAnalyser', () => {
},
{
id: expect.any(String),
name: 'website',
edges: [],
name: 'db',
group: 'component',
path: '/pkgs/website',
inComponent: expect.any(String),
tech: null,
languages: {
CSS: 1,
HTML: 1,
JSON: 3,
JavaScript: 2,
SCSS: 1,
TypeScript: 7,
},
techs: [
'css',
'html',
'javascript',
'nodejs',
'react',
'scss',
'tailwind',
'typescript',
'vercel',
'vite',
],
edges: [],
languages: {},
path: '/docker-compose.yml',
tech: 'postgresql',
techs: [],
inComponent: null,
},
{
id: expect.any(String),
Expand Down Expand Up @@ -161,6 +122,46 @@ describe('techAnalyser', () => {
'vite',
],
},
{
id: expect.any(String),
name: 'vercel',
group: 'hosting',
languages: {},
edges: [],
path: '/pkgs/app',
tech: 'vercel',
inComponent: null,
techs: [],
},
{
id: expect.any(String),
name: 'website',
edges: [],
group: 'component',
path: '/pkgs/website',
inComponent: expect.any(String),
tech: null,
languages: {
CSS: 1,
HTML: 1,
JSON: 3,
JavaScript: 2,
SCSS: 1,
TypeScript: 7,
},
techs: [
'css',
'html',
'javascript',
'nodejs',
'react',
'scss',
'tailwind',
'typescript',
'vercel',
'vite',
],
},
],
techs: [
'css',
Expand Down
20 changes: 11 additions & 9 deletions src/payload/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@ export function findImplicitComponent(pl: Payload, tech: AllowedKeys) {
group = 'thirdparty';
}

pl.addComponent(
new Payload({
name: tech,
tech: tech,
folderPath: pl.path,
group,
parent: pl,
})
);
const comp = new Payload({
name: tech,
tech: tech,
folderPath: pl.path,
group,
parent: pl,
});
pl.addComponent(comp);
if (group !== 'hosting') {
pl.addEdges(comp.id);
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/payload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export class Payload {

merge(pl: Payload) {
pl.components.forEach((component) => this.addComponent(component));
this.addTechs([...pl.techs]);
pl.techs.forEach((tech) => this.techs.add(tech));

if (pl.name !== 'virtual') {
this.addComponent(pl);
Expand Down

0 comments on commit 541e8ba

Please sign in to comment.