Skip to content

Commit 2ad9969

Browse files
authored
Merge pull request #5 from Sirivasv/feat/add-dockerhub
feat: Add Dockerhub action and refactored package to be esmodule comp…
2 parents 8ea3fe5 + e29c225 commit 2ad9969

File tree

8 files changed

+86
-7
lines changed

8 files changed

+86
-7
lines changed

.github/workflows/dockerhub.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Build and publish Docker image
2+
3+
on:
4+
push:
5+
tags:
6+
- '*.*.*'
7+
8+
jobs:
9+
docker-build-and-publish:
10+
environment:
11+
name: dockerhub
12+
permissions:
13+
contents: read
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Docker meta
17+
id: meta
18+
uses: docker/metadata-action@v5
19+
with:
20+
# list of Docker images to use as base name for tags
21+
images: |
22+
name/bmssp-js
23+
# generate Docker tags based on the following events/attributes
24+
tags: |
25+
type=semver,pattern={{version}}
26+
type=semver,pattern={{major}}.{{minor}}
27+
type=semver,pattern={{major}}
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
31+
- name: Login to Docker Hub
32+
uses: docker/login-action@v3
33+
with:
34+
username: ${{ secrets.DOCKERHUB_USERNAME }}
35+
password: ${{ secrets.DOCKERHUB_TOKEN }}
36+
37+
- name: Set up QEMU
38+
uses: docker/setup-qemu-action@v3
39+
40+
- name: Set up Docker Buildx
41+
uses: docker/setup-buildx-action@v3
42+
43+
- name: Build and push
44+
uses: docker/build-push-action@v6
45+
with:
46+
context: .
47+
platforms: linux/amd64,linux/arm64
48+
push: true
49+
tags: ${{ steps.meta.outputs.tags }}

.github/workflows/npmjs.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
jobs:
66
build-and-publish:
77
environment:
8-
name: npmjs-publish
8+
name: npm-bmssp
99
runs-on: ubuntu-latest
1010
permissions:
1111
contents: read
@@ -17,6 +17,7 @@ jobs:
1717
with:
1818
node-version: '24.x'
1919
registry-url: 'https://registry.npmjs.org'
20+
- run: npm test
2021
- run: npm ci
2122
- run: npm publish --provenance --access public
2223
env:

Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM node:24-alpine
2+
3+
WORKDIR /app
4+
5+
# Copy package files and install dependencies
6+
COPY package*.json ./
7+
RUN npm install
8+
9+
# Mount src/ directory as a volume
10+
VOLUME ["src/", "tests/"]
11+
12+
# Default command (can be overridden)
13+
CMD ["node", "tests/main.js"]

index.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bmssp",
3-
"version": "0.4.0",
3+
"version": "0.5.0",
44
"description": "Javascript package implementation of the bmssp algorithm.",
55
"keywords": [
66
"shortest-paths",
@@ -18,12 +18,12 @@
1818
},
1919
"license": "MPL-2.0",
2020
"author": "Saul Ivan Rivas Vega",
21-
"type": "commonjs",
21+
"type": "module",
2222
"main": "index.js",
2323
"directories": {
2424
"doc": "docs"
2525
},
2626
"scripts": {
27-
"test": "echo \"Error: no test specified\" && exit 1"
27+
"test": "node tests/main.js"
2828
}
2929
}

src/bmssp.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function printMessage(message) {
2+
console.log(message);
3+
}
4+
5+
export { printMessage };

tests/main.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { printMessage } from "../src/bmssp.mjs";
2+
3+
function testFunction() {
4+
try {
5+
const result = printMessage("Hello, World!");
6+
console.log('Test passed:', result);
7+
} catch (error) {
8+
console.error('Test failed:', error.message);
9+
}
10+
}
11+
12+
testFunction();

0 commit comments

Comments
 (0)