Skip to content

Commit f1992eb

Browse files
bors[bot]MikailBag
andauthored
Merge #6
6: Add artifact r=MikailBag a=MikailBag Generated image contains pps-cli binary and preconfigured build environment. Co-authored-by: Mikail Bagishov <[email protected]>
2 parents 320801a + ea5e31c commit f1992eb

File tree

10 files changed

+84
-8
lines changed

10 files changed

+84
-8
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/target
2+
Readme.md

.github/workflows/publish.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# GENERATED FILE DO NOT EDIT
2+
name: publish
3+
"on":
4+
pull_request: {}
5+
push:
6+
branches:
7+
- staging
8+
- trying
9+
- master
10+
jobs:
11+
publish:
12+
if: github.event_name == 'push'
13+
env:
14+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15+
runs-on: ubuntu-20.04
16+
timeout-minutes: 15
17+
steps:
18+
- name: Fetch sources
19+
uses: actions/checkout@v2
20+
- name: Build artifacts
21+
run: bash ci/publish-build.sh
22+
- name: Publish docker images
23+
run: bash ci/publish-images.sh

.gitignore

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

build-env/Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Build context: parent directory
2+
FROM rust:slim-bullseye as create-build-env
3+
RUN apt-get update && apt-get install -y --no-install-recommends \
4+
gcc g++ cmake python3 make
5+
COPY . /pps
6+
WORKDIR /pps
7+
ENV PYTHONUNBUFFERED=1
8+
RUN python3 ./build-env/make.py --out /build-env
9+
10+
FROM rust:slim as build-pps
11+
COPY . /pps
12+
WORKDIR /pps
13+
RUN cargo install --path cli
14+
15+
FROM ubuntu:focal
16+
RUN apt-get update && apt-get install -y --no-install-recommends \
17+
gcc g++ cmake python3 make
18+
WORKDIR /usr/local/bin
19+
COPY --from=build-pps /usr/local/cargo/bin/pps-cli pps-cli
20+
COPY --from=create-build-env /build-env /opt/pps-build-env
21+
ENV JJS_PATH=/opt/pps-build-env

build-env/Readme.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Build environment
2+
3+
Build environment is files which are used when pss compiles problems.
4+
5+
## Creation
6+
7+
`make.py` is a script that creates environment locally.
8+
9+
`Dockerfile` defines container image with an environment and other necessary tools.

make-build-env.py renamed to build-env/make.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import argparse
44
import tempfile
55
import os
6+
import os.path
67
import subprocess
78
import shutil
89

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

2529
DESCRIPTION = '''
26-
Script that compiles PPS problem build environment.
27-
28-
This environment contains files that are used when compiling or
29-
importing problems.
30+
Script that creates PPS problem build environment.
3031
'''
3132

3233
parser = argparse.ArgumentParser(description=DESCRIPTION)

ci/config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# TODO: add artifacts
2-
noPublish: true
1+
dockerImages:
2+
- pps-cli
33
buildTimeoutMinutes: 15

ci/e2e-run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ set -euxo pipefail
33

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

6-
python3 make-build-env.py --out $HOME/build-env
6+
python3 build-env/make.py --out $HOME/build-env
77
export JJS_PATH=$HOME/build-env
88
for i in a-plus-b array-sum sqrt; do
99
mkdir -p ./out/$i

ci/publish-build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
set -euxo pipefail
2+
export DOCKER_BUILDKIT=1
3+
docker build -f build-env/Dockerfile -t pps-cli .

ci/publish-images.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
set -euxo pipefail
2+
3+
# GENERATED FILE DO NOT EDIT
4+
if [ "$GITHUB_REF" = "refs/heads/master" ]
5+
then
6+
TAG="latest"
7+
elif [ "$GITHUB_REF" = "refs/heads/trying" ]
8+
then
9+
TAG="dev"
10+
else
11+
echo "unknown GITHUB_REF: $GITHUB_REF"
12+
exit 1
13+
fi
14+
echo $GITHUB_TOKEN | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
15+
docker tag pps-cli ghcr.io/jjs-dev/pps-cli:$TAG
16+
docker push ghcr.io/jjs-dev/pps-cli:$TAG

0 commit comments

Comments
 (0)