Skip to content
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
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/target
Readme.md
23 changes: 23 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# GENERATED FILE DO NOT EDIT
name: publish
"on":
pull_request: {}
push:
branches:
- staging
- trying
- master
jobs:
publish:
if: github.event_name == 'push'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
runs-on: ubuntu-20.04
timeout-minutes: 15
steps:
- name: Fetch sources
uses: actions/checkout@v2
- name: Build artifacts
run: bash ci/publish-build.sh
- name: Publish docker images
run: bash ci/publish-images.sh
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target
21 changes: 21 additions & 0 deletions build-env/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Build context: parent directory
FROM rust:slim-bullseye as create-build-env
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc g++ cmake python3 make
COPY . /pps
WORKDIR /pps
ENV PYTHONUNBUFFERED=1
RUN python3 ./build-env/make.py --out /build-env

FROM rust:slim as build-pps
COPY . /pps
WORKDIR /pps
RUN cargo install --path cli

FROM ubuntu:focal
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc g++ cmake python3 make
WORKDIR /usr/local/bin
COPY --from=build-pps /usr/local/cargo/bin/pps-cli pps-cli
COPY --from=create-build-env /build-env /opt/pps-build-env
ENV JJS_PATH=/opt/pps-build-env
9 changes: 9 additions & 0 deletions build-env/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Build environment

Build environment is files which are used when pss compiles problems.

## Creation

`make.py` is a script that creates environment locally.

`Dockerfile` defines container image with an environment and other necessary tools.
11 changes: 6 additions & 5 deletions make-build-env.py → build-env/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import argparse
import tempfile
import os
import os.path
import subprocess
import shutil

Expand All @@ -17,16 +18,16 @@ def main(args):
subprocess.run(["cargo", "build", "-p", "svaluer", "-Zunstable-options", "--out-dir", f"{args.tmp}"], env=env, check=True)
shutil.copy(f"{args.tmp}/svaluer", f"{args.out}/bin/svaluer")
if "jtl" in args.filter:
install_dir = os.path.realpath(args.out)
print("Configuring JTL")
subprocess.run(["cmake", "-S", f"{args.source}/jtl", "-B", f"{args.tmp}/cmake", f"-DCMAKE_INSTALL_PREFIX={install_dir}"], check=True)
print("Building JTL")
subprocess.run(["cmake", "-S", f"{args.source}/jtl", "-B", f"{args.tmp}/cmake", f"-DCMAKE_INSTALL_PREFIX={args.out}"], check=True)
subprocess.run(["cmake", "--build", f"{args.tmp}/cmake"], check=True)
print(f"Installing JTL to {install_dir}")
subprocess.run(["cmake", "--install", f"{args.tmp}/cmake"], check=True)

DESCRIPTION = '''
Script that compiles PPS problem build environment.

This environment contains files that are used when compiling or
importing problems.
Script that creates PPS problem build environment.
'''

parser = argparse.ArgumentParser(description=DESCRIPTION)
Expand Down
4 changes: 2 additions & 2 deletions ci/config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# TODO: add artifacts
noPublish: true
dockerImages:
- pps-cli
buildTimeoutMinutes: 15
2 changes: 1 addition & 1 deletion ci/e2e-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -euxo pipefail

sudo chmod +x ./e2e-artifacts/pps-cli

python3 make-build-env.py --out $HOME/build-env
python3 build-env/make.py --out $HOME/build-env
export JJS_PATH=$HOME/build-env
for i in a-plus-b array-sum sqrt; do
mkdir -p ./out/$i
Expand Down
3 changes: 3 additions & 0 deletions ci/publish-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set -euxo pipefail
export DOCKER_BUILDKIT=1
docker build -f build-env/Dockerfile -t pps-cli .
16 changes: 16 additions & 0 deletions ci/publish-images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
set -euxo pipefail

# GENERATED FILE DO NOT EDIT
if [ "$GITHUB_REF" = "refs/heads/master" ]
then
TAG="latest"
elif [ "$GITHUB_REF" = "refs/heads/trying" ]
then
TAG="dev"
else
echo "unknown GITHUB_REF: $GITHUB_REF"
exit 1
fi
echo $GITHUB_TOKEN | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
docker tag pps-cli ghcr.io/jjs-dev/pps-cli:$TAG
docker push ghcr.io/jjs-dev/pps-cli:$TAG