Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Fix CI; add docker build for local reproducibility. #158

Merged
merged 1 commit into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.git
30 changes: 23 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
---
name: ci

# Run on push and once a week to keep the images from bitrotting and to
# identify issues while no commits are being pushed.
on:
push:
branches: [master]
pull_request:
branches: [master]
schedule:
- cron: '0 4 * * *' # Run at 04:00 every day.
- cron: "52 2 * * 0"

# Cancel old PR builds when pushing new commits.
concurrency:
group: build-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [10.x, 12.x, 13.x]
node-version: [12.x, 13.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: sudo apt-get install libopus-dev libsodium-dev libvpx-dev
Expand All @@ -43,3 +49,13 @@ jobs:
- run: npm run report-coverage
- run: npm run format && git diff --exit-code
if: ${{ matrix.node-version == '13.x' }}

docker:
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Docker Build
uses: docker/build-push-action@v2
with:
tags: toxchat/js-toxcore-c:latest
21 changes: 12 additions & 9 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")
load("//tools/project:build_defs.bzl", "project")

project(license = "gpl3-https")

#exports_files(srcs = ["package.json"])
#
#nodejs_binary(
# name = "js-toxcore-c",
# entry_point = "lib/main.js",
# visibility = ["//visibility:public"],
# deps = ["@yarn_modules//:_all_"],
#)
exports_files(srcs = [
"package.json",
"package-lock.json",
])

nodejs_binary(
name = "js-toxcore-c",
data = glob(["lib/*.js"]), # + ["@npm//ref-napi"],
entry_point = "lib/main.js",
visibility = ["//visibility:public"],
)
34 changes: 34 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM ubuntu:22.04

RUN apt-get update && \
DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \
ca-certificates \
build-essential \
cmake \
git \
libopus-dev \
libsodium-dev \
libvpx-dev \
ninja-build \
nodejs \
npm \
pkg-config \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /work/c-toxcore
RUN git clone --depth=1 --recurse-submodules --shallow-submodules --branch=master https://github.com/TokTok/c-toxcore.git /work/c-toxcore
RUN cmake -B_build -H. -GNinja
RUN cmake --build _build --target install

WORKDIR /work/js-toxcore-c
COPY . /work/js-toxcore-c/
ENV LD_LIBRARY_PATH=/usr/local/lib
RUN ls -l /usr/local/lib/libtoxcore.so
RUN npm install
RUN npm run doc
RUN npm run test
RUN npm run coverage
RUN npm run format
#COPY . /work/js-toxcore-c.orig/
#RUN diff -ru /work/js-toxcore-c /work/js-toxcore-c.orig
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"scripts": {
"doc": "grunt jsdoc",
"test": "nyc mocha",
"report-coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov",
"coverage": "nyc report --reporter=text-lcov > coverage.lcov",
"report-coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov",
"format": "prettier --write \"**/*.js\" \"**/*.ts\" \"**/*.json\""
},
"dependencies": {
Expand Down
14 changes: 7 additions & 7 deletions tools/install-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
set -eux

# install toxcore
if ! [ -d toxcore ]; then
git clone --depth=1 --branch=master https://github.com/TokTok/toxcore.git toxcore
if ! [ -d c-toxcore ]; then
git clone --depth=1 --recurse-submodules --shallow-submodules --branch=master https://github.com/TokTok/c-toxcore
fi
cd toxcore
git rev-parse HEAD >toxcore.sha
if ! ([ -f "$CACHE_DIR/toxcore.sha" ] && diff "$CACHE_DIR/toxcore.sha" toxcore.sha); then
cd c-toxcore
git rev-parse HEAD >c-toxcore.sha
if ! ([ -f "$CACHE_DIR/c-toxcore.sha" ] && diff "$CACHE_DIR/c-toxcore.sha" c-toxcore.sha); then
cmake -B_build -H. -DCMAKE_INSTALL_PREFIX:PATH="$HOME/cache/usr"
make -C_build -j"$(nproc)"
make -C_build install
mv toxcore.sha "$CACHE_DIR/toxcore.sha"
mv c-toxcore.sha "$CACHE_DIR/c-toxcore.sha"
fi
cd ..
rm -rf toxcore
rm -rf c-toxcore
Loading