Skip to content

Commit 553cb39

Browse files
committed
chore: Fix CI; add docker build for local reproducibility.
1 parent 7d0b826 commit 553cb39

File tree

6 files changed

+79
-24
lines changed

6 files changed

+79
-24
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/.git

.github/workflows/ci.yaml

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
1-
---
1+
name: ci
2+
3+
# Run on push and once a week to keep the images from bitrotting and to
4+
# identify issues while no commits are being pushed.
25
on:
3-
push:
4-
branches: [master]
56
pull_request:
67
branches: [master]
78
schedule:
8-
- cron: '0 4 * * *' # Run at 04:00 every day.
9+
- cron: "52 2 * * 0"
10+
11+
# Cancel old PR builds when pushing new commits.
12+
concurrency:
13+
group: build-${{ github.event.pull_request.number || github.ref }}
14+
cancel-in-progress: true
915

1016
jobs:
1117
build:
12-
runs-on: ubuntu-18.04
18+
runs-on: ubuntu-latest
1319

1420
strategy:
1521
matrix:
16-
node-version: [10.x, 12.x, 13.x]
22+
node-version: [12.x, 13.x]
1723

1824
steps:
1925
- uses: actions/checkout@v2
2026
- name: Use Node.js ${{ matrix.node-version }}
21-
uses: actions/setup-node@v1
27+
uses: actions/setup-node@v4
2228
with:
2329
node-version: ${{ matrix.node-version }}
2430
- run: sudo apt-get install libopus-dev libsodium-dev libvpx-dev
@@ -43,3 +49,13 @@ jobs:
4349
- run: npm run report-coverage
4450
- run: npm run format && git diff --exit-code
4551
if: ${{ matrix.node-version == '13.x' }}
52+
53+
docker:
54+
runs-on: ubuntu-latest
55+
steps:
56+
- name: Set up Docker Buildx
57+
uses: docker/setup-buildx-action@v1
58+
- name: Docker Build
59+
uses: docker/build-push-action@v2
60+
with:
61+
tags: toxchat/js-toxcore-c:latest

BUILD.bazel

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
#load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")
1+
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")
22
load("//tools/project:build_defs.bzl", "project")
33

44
project(license = "gpl3-https")
55

6-
#exports_files(srcs = ["package.json"])
7-
#
8-
#nodejs_binary(
9-
# name = "js-toxcore-c",
10-
# entry_point = "lib/main.js",
11-
# visibility = ["//visibility:public"],
12-
# deps = ["@yarn_modules//:_all_"],
13-
#)
6+
exports_files(srcs = [
7+
"package.json",
8+
"package-lock.json",
9+
])
10+
11+
nodejs_binary(
12+
name = "js-toxcore-c",
13+
data = glob(["lib/*.js"]), # + ["@npm//ref-napi"],
14+
entry_point = "lib/main.js",
15+
visibility = ["//visibility:public"],
16+
)

Dockerfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
FROM ubuntu:22.04
2+
3+
RUN apt-get update && \
4+
DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \
5+
ca-certificates \
6+
build-essential \
7+
cmake \
8+
git \
9+
libopus-dev \
10+
libsodium-dev \
11+
libvpx-dev \
12+
ninja-build \
13+
nodejs \
14+
npm \
15+
pkg-config \
16+
&& apt-get clean \
17+
&& rm -rf /var/lib/apt/lists/*
18+
19+
WORKDIR /work/c-toxcore
20+
RUN git clone --depth=1 --recurse-submodules --shallow-submodules --branch=master https://github.com/TokTok/c-toxcore.git /work/c-toxcore
21+
RUN cmake -B_build -H. -GNinja
22+
RUN cmake --build _build --target install
23+
24+
WORKDIR /work/js-toxcore-c
25+
COPY . /work/js-toxcore-c/
26+
ENV LD_LIBRARY_PATH=/usr/local/lib
27+
RUN ls -l /usr/local/lib/libtoxcore.so
28+
RUN npm install
29+
RUN npm run doc
30+
RUN npm run test
31+
RUN npm run coverage
32+
RUN npm run format
33+
#COPY . /work/js-toxcore-c.orig/
34+
#RUN diff -ru /work/js-toxcore-c /work/js-toxcore-c.orig

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
"scripts": {
3232
"doc": "grunt jsdoc",
3333
"test": "nyc mocha",
34-
"report-coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov",
34+
"coverage": "nyc report --reporter=text-lcov > coverage.lcov",
35+
"report-coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov",
3536
"format": "prettier --write \"**/*.js\" \"**/*.ts\" \"**/*.json\""
3637
},
3738
"dependencies": {

tools/install-deps.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
set -eux
44

55
# install toxcore
6-
if ! [ -d toxcore ]; then
7-
git clone --depth=1 --branch=master https://github.com/TokTok/toxcore.git toxcore
6+
if ! [ -d c-toxcore ]; then
7+
git clone --depth=1 --recurse-submodules --shallow-submodules --branch=master https://github.com/TokTok/c-toxcore
88
fi
9-
cd toxcore
10-
git rev-parse HEAD >toxcore.sha
11-
if ! ([ -f "$CACHE_DIR/toxcore.sha" ] && diff "$CACHE_DIR/toxcore.sha" toxcore.sha); then
9+
cd c-toxcore
10+
git rev-parse HEAD >c-toxcore.sha
11+
if ! ([ -f "$CACHE_DIR/c-toxcore.sha" ] && diff "$CACHE_DIR/c-toxcore.sha" c-toxcore.sha); then
1212
cmake -B_build -H. -DCMAKE_INSTALL_PREFIX:PATH="$HOME/cache/usr"
1313
make -C_build -j"$(nproc)"
1414
make -C_build install
15-
mv toxcore.sha "$CACHE_DIR/toxcore.sha"
15+
mv c-toxcore.sha "$CACHE_DIR/c-toxcore.sha"
1616
fi
1717
cd ..
18-
rm -rf toxcore
18+
rm -rf c-toxcore

0 commit comments

Comments
 (0)