Skip to content

Commit 0966f2d

Browse files
committed
Initial commit
0 parents  commit 0966f2d

5 files changed

Lines changed: 195 additions & 0 deletions

File tree

.github/workflows/main.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: main
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
tags:
8+
- 'v*'
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: duckdb/duckdb-wasm-ci-env
13+
14+
jobs:
15+
docker_build:
16+
name: Docker Build
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
packages: write
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v2
25+
26+
- name: Log in to the Container registry
27+
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
28+
with:
29+
registry: ${{ env.REGISTRY }}
30+
username: ${{ github.actor }}
31+
password: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- run: |-
34+
echo "IMAGE_TAG=$(cat ./TAG)" >> $GITHUB_ENV
35+
shell: bash
36+
37+
# Temporary fix to test the new github cache.
38+
# Delete buildx setup when this is GA.
39+
# https://github.com/docker/buildx/pull/535
40+
- name: Set up Docker Buildx
41+
uses: docker/setup-buildx-action@v1
42+
with:
43+
version: v0.6.0-rc1
44+
driver-opts: image=moby/buildkit:v0.9.0-rc2
45+
buildkitd-flags: --debug
46+
47+
- name: Build and push Docker image
48+
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
49+
with:
50+
context: .
51+
file: ./Dockerfile
52+
push: ${{ github.event_name != 'pull_request' }}
53+
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
54+
cache-from: type=gha
55+
cache-to: type=gha
56+
57+
test_action:
58+
name: Test Action
59+
runs-on: ubuntu-latest
60+
needs:
61+
- docker_build
62+
63+
steps:
64+
- name: Checkout repository
65+
uses: actions/checkout@v2
66+
67+
- name: Compile hello_world with emcc
68+
uses: ./
69+
with:
70+
script: |-
71+
emcc ./test/hello_world.cc

Dockerfile

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
FROM ubuntu:21.04
2+
3+
RUN apt-get update -qq \
4+
&& DEBIAN_FRONTEND=noninteractive apt-get install -y \
5+
tini build-essential git \
6+
ccache cmake ninja-build llvm clang clang-format clang-tidy curl python python3 \
7+
bison flex \
8+
brotli rsync \
9+
libpthread-stubs0-dev \
10+
libboost-all-dev \
11+
firefox \
12+
wget gnupg ca-certificates procps libxss1 \
13+
zip \
14+
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
15+
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
16+
&& apt-get update \
17+
&& apt-get install -y google-chrome-stable \
18+
&& apt-get clean \
19+
&& rm -rf /var/lib/apt/lists/* /etc/apt/sources.list.d/google.list
20+
21+
ARG EMSDK_VERSION="2.0.25"
22+
RUN mkdir -p /opt/emsdk \
23+
&& cd /opt/emsdk \
24+
&& curl -SL https://github.com/emscripten-core/emsdk/archive/${EMSDK_VERSION}.tar.gz | tar -xz --strip-components=1 \
25+
&& ./emsdk install ${EMSDK_VERSION} ccache-git-emscripten-64bit \
26+
&& ./emsdk activate ${EMSDK_VERSION} ccache-git-emscripten-64bit \
27+
&& /bin/bash ./emsdk_env.sh \
28+
&& rm -rf ./emscripten/tag-*/tests \
29+
&& rm -rf ./emscripten/tag-*/site \
30+
&& rm -rf ./emscripten/tag-*/docs \
31+
&& rm -rf ./zips \
32+
&& find . -name "*.o" -exec rm {} \; \
33+
&& find . -name "*.a" -exec rm {} \; \
34+
&& find . -name "*.tmp" -exec rm {} \;
35+
36+
SHELL ["/bin/bash", "-c"]
37+
38+
ENV NVM_DIR=/opt/nvm
39+
ARG NVM_VERSION="v0.38.0"
40+
ARG NODE_VERSION="v16.1.0"
41+
RUN mkdir -p /opt/nvm \
42+
&& ls -lisah /opt/nvm \
43+
&& curl https://raw.githubusercontent.com/nvm-sh/nvm/${NVM_VERSION}/install.sh | bash \
44+
&& source ${NVM_DIR}/nvm.sh \
45+
&& nvm install ${NODE_VERSION} \
46+
&& nvm alias default ${NODE_VERSION} \
47+
&& nvm use default \
48+
&& npm install --global yarn
49+
50+
ARG RUST_VERSION="1.52.1"
51+
RUN export RUSTUP_HOME=/opt/rust \
52+
&& export CARGO_HOME=/opt/rust \
53+
&& curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain ${RUST_VERSION} -y \
54+
&& export PATH=$PATH:/opt/rust/bin \
55+
&& rustup target add wasm32-unknown-unknown
56+
57+
ARG BOOST_VERSION="1.74.0"
58+
ARG BOOST_TARBALL="boost_1_74_0.tar.gz"
59+
RUN curl -Lo /opt/boost.tar.gz "https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION}/source/${BOOST_TARBALL}"
60+
61+
RUN source /opt/emsdk/emsdk_env.sh \
62+
&& echo "export PATH=$PATH:/opt/rust/bin" >> /opt/env.sh \
63+
&& echo "export EMSDK=$EMSDK" >> /opt/env.sh \
64+
&& echo "export EM_CONFIG=$EM_CONFIG" >> /opt/env.sh \
65+
&& echo "export EMSCRIPTEN=$EMSCRIPTEN" >> /opt/env.sh \
66+
&& echo "export CARGO_HOME=/opt/rust" >> /opt/env.sh \
67+
&& echo "export RUSTUP_HOME=/opt/rust" >> /opt/env.sh \
68+
&& echo "export BOOST_ARCHIVE=/opt/boost.tar.gz" >> /opt/env.sh \
69+
&& echo "source /opt/nvm/nvm.sh" >> /opt/env.sh \
70+
&& printf '#!/bin/bash\nsource /opt/env.sh\nexec env "$@"\n' > /opt/entrypoint.sh \
71+
&& chmod +x /opt/entrypoint.sh
72+
73+
ENTRYPOINT ["tini", "-v", "--", "/opt/entrypoint.sh"]
74+
WORKDIR /github/workspace

TAG

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

action.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
inputs:
2+
script:
3+
description: 'Script to be passed to the docker image'
4+
required: true
5+
6+
emscripten_cache_dir:
7+
description: 'Emscripten cache directory'
8+
default: /github/workspace/.emscripten_cache
9+
yarn_cache_dir:
10+
description: 'Yarn cache directory'
11+
default: /github/workspace/.yarn_cache
12+
ccache_dir:
13+
description: 'Ccache directory'
14+
default: /github/workspace/.ccache
15+
16+
env:
17+
REGISTRY: ghcr.io
18+
IMAGE_NAME: duckdb/duckdb-wasm-ci-env
19+
20+
runs:
21+
using: 'composite'
22+
steps:
23+
- run: |-
24+
echo "IMAGE_TAG=$(cat ./TAG)" >> $GITHUB_ENV
25+
shell: bash
26+
27+
- run: |-
28+
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
29+
shell: bash
30+
31+
- run: |-
32+
docker run --rm \
33+
-v ${{ github.workspace }}:/github/workspace/ \
34+
-v ${{ inputs.emscripten_cache_dir }}:/mnt/emscripten_cache/ \
35+
-v ${{ inputs.yarn_cache_dir }}:/mnt/yarn_cache/ \
36+
-v ${{ inputs.ccache_dir }}:/mnt/ccache/ \
37+
-e EM_CACHE=/mnt/emscripten_cache \
38+
-e YARN_CACHE_FOLDER=/mnt/yarn_cache \
39+
-e CCACHE_DIR=/mnt/ccache \
40+
-e CCACHE_BASEDIR=/github/workspace \
41+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} \
42+
bash -c "${{ inputs.script }}"
43+
shell: bash

test/hello_world.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include <stdio.h>
2+
3+
int main() {
4+
printf("hello, world!\n");
5+
return 0;
6+
}

0 commit comments

Comments
 (0)