Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
ci: build linux binary on alpine with static linking (#60)
* ci: would this work?

* ci: add docker:// to release pipeline

* ci: add artifacts to test ppx on alpine

* ci: try static linking

* ci: try static linking

* ci: are we in alpine? how this works?

* ci: are we in alpine? how this works?

* ci: are we in alpine? how this works?

* ci: are we in alpine? how this works?

* ci: are we in alpine? how this works?

* ci: try container action

* ci: try custom container for building alpine image

* ci: adjust release workflow to use docker container
  • Loading branch information
baransu committed Jan 6, 2020
1 parent dc392f7 commit 9a4f31b
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 4 deletions.
34 changes: 34 additions & 0 deletions .ci/Dockerfile
@@ -0,0 +1,34 @@
################################################################################
# Dockerfile used for building linux/alpine binary
# taken from https://github.com/anmonteiro/gh-feed-reader/blob/master/Dockerfile
################################################################################

# start from node image so we can install esy from npm
FROM node:12-alpine as build

ENV TERM=dumb LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/lib

RUN mkdir /esy
WORKDIR /esy

ENV NPM_CONFIG_PREFIX=/esy
RUN npm install -g --unsafe-perm @esy-nightly/esy

# now that we have esy installed we need a proper runtime

FROM alpine:3.8 as esy

ENV TERM=dumb LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/lib

WORKDIR /

COPY --from=build /esy /esy

RUN apk add --no-cache ca-certificates wget bash curl perl-utils git patch \
gcc g++ musl-dev make m4 linux-headers coreutils

RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub
RUN wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.28-r0/glibc-2.28-r0.apk
RUN apk add --no-cache glibc-2.28-r0.apk

ENV PATH=/esy/bin:$PATH
51 changes: 50 additions & 1 deletion .github/workflows/pipeline.yml
Expand Up @@ -9,13 +9,62 @@ on:
- master

jobs:
test_and_build_alpine:
name: Test on node ${{ matrix.node_version }} and ${{ matrix.os }} with alpine Docker
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [12.x]
os: [ubuntu-latest]

container:
image: cichocinski/node-with-esy:12-alpine

steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: setup
run: |
npm install -g cross-env
# OCaml 4.06 and BuckleScript 6
- name: install-build
run: |
esy install
esy dune build --root . --only-packages graphql_ppx --ignore-promoted-rules --no-config --profile release-static
- name: test-native
run: |
esy b dune runtest -f
- name: test-bsb6
run: |
cd tests_bucklescript
node ./run.js bsb6
# OCaml 4.02 and BuckleScript 5
- name: install-build @402
run: |
esy @402 install
esy @402 dune build --root . --only-packages graphql_ppx --ignore-promoted-rules --no-config --profile release-static
- name: test-bsb5
run: |
cd tests_bucklescript
node ./run.js bsb5
- name: Upload artifacts ${{ matrix.os }}
uses: actions/upload-artifact@master
with:
name: ${{ matrix.os }}
path: _build/default/src/bucklescript_bin/bin.exe
env:
CI: true

test_and_build:
name: Test on node ${{ matrix.node_version }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [12.x]
os: [ubuntu-latest, windows-latest, macOS-latest]
os: [windows-latest, macOS-latest]

steps:
- uses: actions/checkout@v1
Expand Down
54 changes: 54 additions & 0 deletions .github/workflows/release.yml
Expand Up @@ -6,6 +6,60 @@ on:
- v*

jobs:
test_and_build_alpine:
name: Test on node ${{ matrix.node_version }} and ${{ matrix.os }} with alpine Docker
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [12.x]
os: [ubuntu-latest]

container:
image: cichocinski/node-with-esy:12-alpine

steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: setup
run: |
npm install -g esy@latest cross-env
# OCaml 4.06 and BuckleScript 6
- name: install-build
run: |
esy install
esy dune build --root . --only-packages graphql_ppx --ignore-promoted-rules --no-config --profile release-static
- name: test-native
run: |
esy b dune runtest -f
- name: test-bsb6
run: |
cd tests_bucklescript
node ./run.js bsb6
- name: Upload artifacts ${{ matrix.os }}
uses: actions/upload-artifact@master
with:
name: ${{ matrix.os }}-bsb6
path: _build/default/src/bucklescript_bin/bin.exe
# OCaml 4.02 and BuckleScript 5
- name: install-build @402
run: |
esy @402 install
esy @402 dune build --root . --only-packages graphql_ppx --ignore-promoted-rules --no-config --profile release-static
- name: test-bsb5
run: |
cd tests_bucklescript
node ./run.js bsb5
- name: Upload artifacts ${{ matrix.os }}
uses: actions/upload-artifact@master
with:
name: ${{ matrix.os }}
path: _build/default/src/bucklescript_bin/bin.exe
env:
CI: true

test_and_build:
name: Test on node ${{ matrix.node_version }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
Expand Down
3 changes: 2 additions & 1 deletion 402.json
@@ -1,4 +1,5 @@
{
"name": "graphql_ppx",
"dependencies": {
"@opam/dune": "*",
"@opam/result": "*",
Expand All @@ -15,7 +16,7 @@
"ocaml": "~4.2.0"
},
"esy": {
"build": "refmterr dune build -p graphql_ppx",
"build": [["dune", "build", "-p", "#{self.name}"]],
"buildsInSource": "_build"
}
}
3 changes: 3 additions & 0 deletions dune-workspace
@@ -0,0 +1,3 @@
(lang dune 1.1)

(env (release-static (flags (:standard -ccopt -static))))
3 changes: 2 additions & 1 deletion esy.json
@@ -1,4 +1,5 @@
{
"name": "graphql_ppx",
"dependencies": {
"@opam/dune": "*",
"@opam/result": "*",
Expand All @@ -17,7 +18,7 @@
"ocaml": ">= 4.6.0"
},
"esy": {
"build": "refmterr dune build -p graphql_ppx",
"build": [["dune", "build", "-p", "#{self.name}"]],
"buildsInSource": "_build"
}
}
2 changes: 1 addition & 1 deletion src/bucklescript/output_bucklescript_unifier.re
Expand Up @@ -13,7 +13,7 @@ open Output_bucklescript_utils;
exception Unimplemented(string);

let make_make_fun = (config, variable_defs) => {
let make_tuple = (loc, variables, compose) => [%expr
let make_tuple = (_loc, _variables, compose) => [%expr
(
parse,
ppx_printed_query,
Expand Down

0 comments on commit 9a4f31b

Please sign in to comment.