Skip to content
Closed
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
48 changes: 48 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

# All of the following environment variables are required to set default values
# for the parameters in docker-compose.yml.

# empty prefix means that the docker-compose configuration will use named
# volumes which potentially improves the performance on docker for macos and
# docker for windows, it also prevents the contamination of the source
# directory
# a non-empty prefix means that directories from the host are bind-mounted
# into the container, it should be set to ".docker/" on github actions to keep
# the cache plugin functional
DOCKER_VOLUME_PREFIX=

# turn on inline build cache, this is a docker buildx feature documented
# at https://github.com/docker/buildx#--cache-tonametypetypekeyvalue
BUILDKIT_INLINE_CACHE=1
COMPOSE_DOCKER_CLI_BUILD=1
DOCKER_BUILDKIT=1

# different architecture notations
ARCH=amd64
ARCH_ALIAS=x86_64
ARCH_SHORT=amd64

# The default Debian version to use for the docker image
DEBIAN=12

# Default repository to pull and push images from
REPO=ghcr.io/apache/arrow-js-dev

# Default versions for various dependencies
NODE=18
116 changes: 116 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

name: NodeJS


on:
push:
branches:
- '**'
- '!dependabot/**'
tags:
- '**'
pull_request:

concurrency:
group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }}
cancel-in-progress: true

permissions:
contents: read

env:
DOCKER_VOLUME_PREFIX: ".docker/"

jobs:

docker:
name: AMD64 Debian 12 NodeJS 18
runs-on: ubuntu-latest
if: ${{ !contains(github.event.pull_request.title, 'WIP') }}
timeout-minutes: 45
steps:
- name: Checkout Arrow JS
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
with:
fetch-depth: 0
- name: Execute Docker Build
run: |
docker compose run debian-js

macos:
name: AMD64 macOS 13 NodeJS ${{ matrix.node }}
runs-on: macos-13
if: ${{ !contains(github.event.pull_request.title, 'WIP') }}
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
node: [18]
steps:
- name: Checkout Arrow JS
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Jest Cache
uses: actions/cache@v4
with:
path: .jest-cache
key: js-jest-cache-${{ runner.os }}-${{ hashFiles('src/**/*.ts', 'test/**/*.ts', 'yarn.lock') }}
restore-keys: js-jest-cache-${{ runner.os }}-
- name: Install NodeJS
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Build
shell: bash
run: ci/scripts/js_build.sh $(pwd) /tmp/build
- name: Test
shell: bash
run: ci/scripts/js_test.sh /tmp/build

windows:
name: AMD64 Windows NodeJS ${{ matrix.node }}
runs-on: windows-latest
if: ${{ !contains(github.event.pull_request.title, 'WIP') }}
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
node: [18]
steps:
- name: Checkout Arrow JS
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Jest Cache
uses: actions/cache@v4
with:
path: .jest-cache
key: js-jest-cache-${{ runner.os }}-${{ hashFiles('src/**/*.ts', 'test/**/*.ts', 'yarn.lock') }}
restore-keys: js-jest-cache-${{ runner.os }}-
- name: Install NodeJS
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Build
shell: bash
run: ci/scripts/js_build.sh $(pwd) /tmp/build
- name: Test
shell: bash
run: ci/scripts/js_test.sh /tmp/build
Empty file added LICENSE.txt
Empty file.
Empty file added NOTICE.txt
Empty file.
28 changes: 28 additions & 0 deletions ci/docker/debian-12-js.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

ARG arch=amd64
ARG node=18
FROM ${arch}/node:${node}

ENV NODE_NO_WARNINGS=1

# install rsync for copying the generated documentation
RUN apt-get update -y -q && \
apt-get install -y -q --no-install-recommends rsync && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
61 changes: 61 additions & 0 deletions ci/scripts/js_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

set -ex

source_dir=${1}
build_dir=${2}

: ${BUILD_DOCS_JS:=OFF}

# https://github.com/apache/arrow/issues/41429
# TODO: We want to out-of-source build. This is a workaround. We copy
# all needed files to the build directory from the source directory
# and build in the build directory.
rm -rf ${build_dir}/js
mkdir -p ${build_dir}

cp -aL ${source_dir}/LICENSE.txt ${build_dir}/
cp -aL ${source_dir}/NOTICE.txt ${build_dir}/
cp -aL ${source_dir} ${build_dir}/js
pushd ${build_dir}/js

yarn --immutable

yarn lint:ci
yarn build

if [ "${BUILD_DOCS_JS}" == "ON" ]; then
# If apache or upstream are defined use those as remote.
# Otherwise use origin which could be a fork on PRs.
if [ "$(git -C ${source_dir} config --get remote.apache.url)" == "git@github.com:apache/arrow-js.git" ]; then
yarn doc --gitRemote apache
elif [[ "$(git -C ${source_dir}config --get remote.upstream.url)" =~ "https://github.com/apache/arrow-js" ]]; then
yarn doc --gitRemote upstream
elif [[ "$(basename -s .git $(git -C ${source_dir} config --get remote.origin.url))" == "arrow-js" ]]; then
yarn doc
else
echo "Failed to build docs because the remote is not set correctly. Please set the origin or upstream remote to https://github.com/apache/arrow-js.git or the apache remote to git@github.com:apache/arrow-js.git."
exit 0
fi
mkdir -p ${build_dir}/docs/js
rsync -a doc/ ${build_dir}/docs/js
fi

popd
30 changes: 30 additions & 0 deletions ci/scripts/js_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

set -ex

build_dir=${1}/js

pushd ${build_dir}

yarn lint
yarn test
yarn test:bundle

popd
54 changes: 54 additions & 0 deletions docker-compose.yml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use recommended compose.yaml (not .yml) file name for Docker Compose v2?

See also: https://docs.docker.com/compose/gettingstarted/#step-2-define-services-in-a-compose-file

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

# Usage
# -----
#
# The docker compose file is parametrized using environment variables, the
# defaults are set in .env file.
#
# Example:
# $ ARCH=amd64 docker compose build debian-js
# $ ARCH=amd64 docker compose run debian-js

volumes:
debian-ccache:
name: ${ARCH}-debian-${DEBIAN}-ccache
Comment on lines +29 to +30
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to use ccache. We want to use jest instead:

Suggested change
debian-ccache:
name: ${ARCH}-debian-${DEBIAN}-ccache
jest-cache:
name: jest-cache


services:
debian-js:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
debian-js:
debian:

# Usage:
# docker compose build debian-js
# docker compose run debian-js
image: ${REPO}:${ARCH}-debian-${DEBIAN}-js-${NODE}
build:
context: .
dockerfile: ci/docker/debian-${DEBIAN}-js.dockerfile
cache_from:
- ${REPO}:${ARCH}-debian-${DEBIAN}-js-${NODE}
args:
arch: ${ARCH}
node: ${NODE}
volumes: &debian-volumes
- .:/arrow-js:delegated
- ${DOCKER_VOLUME_PREFIX}debian-ccache:/ccache:delegated
environment:
BUILD_DOCS_JS: "ON"
command: &js-command >
/bin/bash -c "
/arrow-js/ci/scripts/js_build.sh /arrow-js /build &&
/arrow-js/ci/scripts/js_test.sh /build"