-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: much more improve on DX and Docker (#10)
* feat(test): add tests to stabilize util.spec.js * feat(test): add tests for response formating on status code and message output * feat(test): add tests to stabilize gitpath * feat(resp): get rid of description module and merge with formatResponse module * feat: lint and clean gitrows small errors * feat(test): start adding tests for gitrows * feat: removed TODO * Updated the README * feat(Dockerfile): upgrade the docker image * fix: version from 0.0.3 to 0.0.4 * feat: updated the CHANGELOG and fix version on lock file * feat(test): add test workflow
- Loading branch information
1 parent
feccb6c
commit 32c48d2
Showing
16 changed files
with
7,459 additions
and
1,041 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,6 @@ node_modules | |
server/*.spec.js | ||
kubernetes | ||
|
||
.env | ||
README.md | ||
digest.json | ||
screen.gif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: CI Tests | ||
|
||
on: [push] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: '22' | ||
cache: 'npm' | ||
cache-dependency-path: package-lock.json | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Tests | ||
run: npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,11 @@ | ||
# This stage installs our modules | ||
FROM mhart/alpine-node:12 | ||
MAINTAINER [email protected] | ||
FROM node:22 | ||
|
||
WORKDIR /app | ||
COPY package.json package-lock.json ./ | ||
|
||
COPY package.json package-lock.json ./ | ||
RUN npm install | ||
|
||
# Then we copy over the modules from above onto a `slim` image | ||
FROM mhart/alpine-node:slim-12 | ||
|
||
RUN apk add --no-cache tini | ||
|
||
WORKDIR /app | ||
COPY --from=0 /app . | ||
COPY . . | ||
|
||
ENTRYPOINT ["/sbin/tini", "--"] | ||
|
||
# Because npm is not installed here | ||
# We will run with the node directly | ||
CMD ["node","index.js"] | ||
CMD ["node","index.js"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
const GitPath = require('./gitpath'); | ||
describe('GitPath', () => { | ||
describe('parse()', () => { | ||
it('should parse a path', () => { | ||
const result = GitPath.parse('/path/to/file.json'); | ||
expect(result).toEqual({ | ||
valid: false, | ||
ns: undefined, | ||
owner: undefined, | ||
repo: "path", | ||
branch: undefined, | ||
path: 'to/file.json', | ||
type: 'json', | ||
resource: undefined | ||
}); | ||
}); | ||
|
||
it('should parse a GitHub URL', () => { | ||
const result = GitPath.parse('https://github.com/owner/repo/blob/main/path/to/file.yaml'); | ||
expect(result).toEqual({ | ||
valid: true, | ||
ns: 'github', | ||
owner: 'owner', | ||
repo: 'repo', | ||
branch: 'main', | ||
path: 'path/to/file.yaml', | ||
type: 'yaml', | ||
}); | ||
}); | ||
|
||
it('should parse a GitLab URL', () => { | ||
const result = GitPath.parse('https://gitlab.com/owner/repo/-/raw/main/path/to/file.csv'); | ||
expect(result).toEqual({ | ||
valid: true, | ||
ns: 'gitlab', | ||
owner: 'owner', | ||
repo: 'repo', | ||
branch: 'main', | ||
path: 'path/to/file.csv', | ||
type: 'csv', | ||
}); | ||
}); | ||
|
||
it('should return input object if already parsed', () => { | ||
const input = { | ||
path: 'path/to/file.json', | ||
type: 'json' | ||
}; | ||
const result = GitPath.parse(input); | ||
expect(result).toBe(input); | ||
}); | ||
}); | ||
|
||
describe('toUrl()', () => { | ||
it('should fail generate a valid URL for an invalid/incomplete path', () => { | ||
const result = GitPath.toUrl('/path/to/file.yaml'); | ||
expect(result).toBe(null); | ||
}); | ||
|
||
it('should generate GitHub URL for a path', () => { | ||
const result = GitPath.toUrl({ | ||
repo:'repo', | ||
owner: 'owner', | ||
ns: 'github', | ||
path: 'path/to/file.yaml', | ||
type: 'yaml' | ||
}); | ||
expect(result).toBe('https://github.com/owner/repo/blob/master/path/to/file.yaml'); | ||
}); | ||
|
||
it('should generate GitLab URL for a path', () => { | ||
const result = GitPath.toUrl({ | ||
repo:'repo', | ||
owner: 'owner', | ||
ns: 'gitlab', | ||
path: 'path/to/file.json', | ||
type: 'json' | ||
}); | ||
expect(result).toBe('https://gitlab.com/owner/repo/-/blob/master/path/to/file.json'); | ||
}); | ||
|
||
it('should handle raw parameter', () => { | ||
const result = GitPath.toUrl({ | ||
repo:'repo', | ||
owner: 'owner', | ||
ns: 'github', | ||
path: 'path/to/file.csv', | ||
type: 'csv' | ||
}, true); | ||
expect(result).toBe('https://raw.githubusercontent.com/owner/repo/master/path/to/file.csv'); | ||
}); | ||
|
||
}); | ||
|
||
describe('toApi()', () => { | ||
it('should generate GitHub API URL for a path', () => { | ||
const result = GitPath.toApi({ | ||
repo:'repo', | ||
owner: 'owner', | ||
ns: 'github', | ||
path: 'path/to/file.json', | ||
type: 'json' | ||
}); | ||
expect(result).toBe('https://api.github.com/repos/owner/repo/contents/path/to/file.json'); | ||
}); | ||
|
||
it('should generate GitLab API URL for a path', () => { | ||
const result = GitPath.toApi({ | ||
repo:'repo', | ||
owner: 'owner', | ||
ns: 'gitlab', | ||
path: 'path/to/file.yaml', | ||
type: 'yaml' | ||
}); | ||
expect(result).toBe('https://gitlab.com/api/v4/projects/owner%2Frepo/repository/files/path%2Fto%2Ffile.yaml'); | ||
}); | ||
}); | ||
|
||
describe('isValid()', () => { | ||
it('should return true for a valid object', () => { | ||
const obj = { | ||
ns: "github", | ||
owner: 'owner', | ||
repo: 'repo', | ||
path: 'path/to/file.json', | ||
type: 'json' | ||
}; | ||
const result = GitPath.isValid(obj); | ||
expect(result).toBe(true); | ||
}); | ||
|
||
it('should return false if type is invalid', () => { | ||
const obj = { | ||
ns: undefined, | ||
owner: 'owner', | ||
repo: 'repo', | ||
path: 'path/to/file.json', | ||
type: 'invalid' | ||
}; | ||
const result = GitPath.isValid(obj); | ||
expect(result).toBe(false); | ||
}); | ||
|
||
it('should return false if mandatory properties are missing', () => { | ||
const obj = { | ||
ns: undefined, | ||
owner: 'owner', | ||
repo: 'repo', | ||
type: 'json' | ||
}; | ||
const result = GitPath.isValid(obj); | ||
expect(result).toBe(false); | ||
}); | ||
}); | ||
|
||
describe('isUrl()', () => { | ||
it('should return true for a valid URL', () => { | ||
const result = GitPath.isUrl('https://github.com/owner/repo/blob/main/path/to/file.yaml'); | ||
expect(result).toBe(true); | ||
}); | ||
|
||
it('should return false for an invalid URL', () => { | ||
const result = GitPath.isUrl('/path/to/file.yaml'); | ||
expect(result).toBe(false); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.