Skip to content

Commit

Permalink
try building deb package
Browse files Browse the repository at this point in the history
  • Loading branch information
andarut committed Oct 24, 2023
1 parent e354737 commit f32ab64
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 95 deletions.
196 changes: 104 additions & 92 deletions .github/workflows/Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ env:
demo_dir: "/home/kitten"

jobs:
# build-linux:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# include:
build-linux:
runs-on: ubuntu-latest
strategy:
matrix:
include:
# - os: buster
# compiler: g++
# cpp: 17
Expand All @@ -34,109 +34,121 @@ jobs:
# cpp: 20
# asan: on
# ubsan: off
# - os: jammy
# compiler: g++
# cpp: 20
# asan: on
# ubsan: off
- os: jammy
compiler: g++
cpp: 20
asan: on
ubsan: off

# name: "${{matrix.os}}/${{matrix.compiler}}/c++${{matrix.cpp}}/asan=${{matrix.asan}}/ubsan=${{matrix.ubsan}}"
name: "${{matrix.os}}/${{matrix.compiler}}/c++${{matrix.cpp}}/asan=${{matrix.asan}}/ubsan=${{matrix.ubsan}}"

# steps:
# - uses: actions/checkout@v3
steps:
- uses: actions/checkout@v3

# - name: Get polyfills repo
# uses: actions/checkout@v3
# with:
# repository: 'VKCOM/kphp-polyfills'
# path: 'kphp-polyfills'
- name: Get polyfills repo
uses: actions/checkout@v3
with:
repository: 'VKCOM/kphp-polyfills'
path: 'kphp-polyfills'

- name: Cache docker image
uses: actions/cache@v3
id: docker-image-cache
with:
path: kphp-build-env-${{matrix.os}}.tar
key: docker-image-cache-${{matrix.os}}-${{ hashFiles('.github/workflows/Dockerfile.*', 'tests/python/requirements.txt') }}

- name: Build and save docker image
if: steps.docker-image-cache.outputs.cache-hit != 'true'
run: |
docker build -f $GITHUB_WORKSPACE/.github/workflows/Dockerfile.${{matrix.os}} $GITHUB_WORKSPACE -t kphp-build-img-${{matrix.os}}
docker save --output kphp-build-env-${{matrix.os}}.tar kphp-build-img-${{matrix.os}}
- name: Load docker image from cache
if: steps.docker-image-cache.outputs.cache-hit == 'true'
run: docker load --input kphp-build-env-${{matrix.os}}.tar

# - name: Cache docker image
# uses: actions/cache@v3
# id: docker-image-cache
# with:
# path: kphp-build-env-${{matrix.os}}.tar
# key: docker-image-cache-${{matrix.os}}-${{ hashFiles('.github/workflows/Dockerfile.*', 'tests/python/requirements.txt') }}
- name: Start docker container
run: |
docker run -dt --name kphp-build-container-${{matrix.os}} kphp-build-img-${{matrix.os}}
docker cp $GITHUB_WORKSPACE/. kphp-build-container-${{matrix.os}}:${{env.kphp_root_dir}}
# - name: Build and save docker image
# if: steps.docker-image-cache.outputs.cache-hit != 'true'
# run: |
# docker build -f $GITHUB_WORKSPACE/.github/workflows/Dockerfile.${{matrix.os}} $GITHUB_WORKSPACE -t kphp-build-img-${{matrix.os}}
# docker save --output kphp-build-env-${{matrix.os}}.tar kphp-build-img-${{matrix.os}}

# - name: Load docker image from cache
# if: steps.docker-image-cache.outputs.cache-hit == 'true'
# run: docker load --input kphp-build-env-${{matrix.os}}.tar
- name: Add git safe directory
run: docker exec kphp-build-container-${{matrix.os}} bash -c
"git config --global --add safe.directory ${{env.kphp_root_dir}}"

# - name: Start docker container
# run: |
# docker run -dt --name kphp-build-container-${{matrix.os}} kphp-build-img-${{matrix.os}}
# docker cp $GITHUB_WORKSPACE/. kphp-build-container-${{matrix.os}}:${{env.kphp_root_dir}}
- name: Build all
run: docker exec kphp-build-container-${{matrix.os}} bash -c
"cmake -DCMAKE_CXX_COMPILER=${{matrix.compiler}} -DCMAKE_CXX_STANDARD=${{matrix.cpp}} -DADDRESS_SANITIZER=${{matrix.asan}} -DUNDEFINED_SANITIZER=${{matrix.ubsan}} -DPDO_DRIVER_MYSQL=ON -DPDO_DRIVER_PGSQL=ON -DPDO_LIBS_STATIC_LINKING=ON -S ${{env.kphp_root_dir}} -B ${{env.kphp_build_dir}} && make -C ${{env.kphp_build_dir}} -j$(nproc) all"

# - name: Add git safe directory
# run: docker exec kphp-build-container-${{matrix.os}} bash -c
# "git config --global --add safe.directory ${{env.kphp_root_dir}}"
# - name: Run unit tests
# run: docker exec kphp-build-container-${{matrix.os}} bash -c
# "make -C ${{env.kphp_build_dir}} -j$(nproc) test"

# - name: Build all
# run: docker exec kphp-build-container-${{matrix.os}} bash -c
# "cmake -DCMAKE_CXX_COMPILER=${{matrix.compiler}} -DCMAKE_CXX_STANDARD=${{matrix.cpp}} -DADDRESS_SANITIZER=${{matrix.asan}} -DUNDEFINED_SANITIZER=${{matrix.ubsan}} -DPDO_DRIVER_MYSQL=ON -DPDO_DRIVER_PGSQL=ON -DPDO_LIBS_STATIC_LINKING=ON -S ${{env.kphp_root_dir}} -B ${{env.kphp_build_dir}} && make -C ${{env.kphp_build_dir}} -j$(nproc) all"
- name: Compile dummy PHP script
run: docker exec kphp-build-container-${{matrix.os}} bash -c
"cd ${{env.kphp_build_dir}} && echo 'hello world' > demo.php && ${{env.kphp_root_dir}}/objs/bin/kphp2cpp --cxx ${{matrix.compiler}} demo.php && kphp_out/server -o --user kitten"

# - name: Run unit tests
# run: docker exec kphp-build-container-${{matrix.os}} bash -c
# "make -C ${{env.kphp_build_dir}} -j$(nproc) test"
# - name: Polyfills composer install
# run: docker exec kphp-build-container-${{matrix.os}} bash -c
# "composer install -d ${{env.kphp_polyfills_dir}}"

# - name: Compile dummy PHP script
# run: docker exec kphp-build-container-${{matrix.os}} bash -c
# "cd ${{env.kphp_build_dir}} && echo 'hello world' > demo.php && ${{env.kphp_root_dir}}/objs/bin/kphp2cpp --cxx ${{matrix.compiler}} demo.php && kphp_out/server -o --user kitten"

# - name: Polyfills composer install
# run: docker exec kphp-build-container-${{matrix.os}} bash -c
# "composer install -d ${{env.kphp_polyfills_dir}}"

# - name: Run python tests
# id: python_tests
# continue-on-error: true
# run: docker exec kphp-build-container-${{matrix.os}} bash -c
# "chown -R kitten /home && su kitten -c 'GITHUB_ACTIONS=1 KPHP_TESTS_POLYFILLS_REPO=${{env.kphp_polyfills_dir}} KPHP_CXX=${{matrix.compiler}} python3.7 -m pytest --tb=native -n$(nproc) ${{env.kphp_root_dir}}/tests/python/'"

# - name: Prepare python tests artifacts
# if: steps.python_tests.outcome == 'failure'
# run: docker cp kphp-build-container-${{matrix.os}}:${{env.kphp_root_dir}}/tests/python/_tmp/ ${{runner.temp}} &&
# rm -rf ${{runner.temp}}/_tmp/*/working_dir

# - name: Upload python tests artifacts
# uses: actions/upload-artifact@v3
# if: steps.python_tests.outcome == 'failure'
# with:
# path: ${{runner.temp}}/_tmp/
# - name: Run python tests
# id: python_tests
# continue-on-error: true
# run: docker exec kphp-build-container-${{matrix.os}} bash -c
# "chown -R kitten /home && su kitten -c 'GITHUB_ACTIONS=1 KPHP_TESTS_POLYFILLS_REPO=${{env.kphp_polyfills_dir}} KPHP_CXX=${{matrix.compiler}} python3.7 -m pytest --tb=native -n$(nproc) ${{env.kphp_root_dir}}/tests/python/'"

# - name: Fail pipeline if python tests failed
# if: steps.python_tests.outcome == 'failure'
# run: exit 1
# - name: Prepare python tests artifacts
# if: steps.python_tests.outcome == 'failure'
# run: docker cp kphp-build-container-${{matrix.os}}:${{env.kphp_root_dir}}/tests/python/_tmp/ ${{runner.temp}} &&
# rm -rf ${{runner.temp}}/_tmp/*/working_dir

# - name: Remove docker container
# run: docker rm -f kphp-build-container-${{matrix.os}}
# - name: Upload python tests artifacts
# uses: actions/upload-artifact@v3
# if: steps.python_tests.outcome == 'failure'
# with:
# path: ${{runner.temp}}/_tmp/

install-linux:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- os: buster
- os: focal
- os: jammy
# - name: Fail pipeline if python tests failed
# if: steps.python_tests.outcome == 'failure'
# run: exit 1

steps:
- uses: actions/checkout@v3
- name: Build deb package
run: docker exec kphp-build-container-${{matrix.os}} bash -c
'cd ${{env.kphp_build_dir}} && cpack -D CPACK_COMPONENTS_ALL="KPHP;FLEX" . && ls'

- name: Build and start Docker container
run: |
docker build -f $GITHUB_WORKSPACE/.github/workflows/Dockerfile.${{matrix.os}}.install $GITHUB_WORKSPACE -t kphp-build-img-${{matrix.os}}-install
docker run -dt --name kphp-build-container-${{matrix.os}}-install kphp-build-img-${{matrix.os}}-install
- name: Install deb package
run: docker exec kphp-build-container-${{matrix.os}} bash -c
"cd ${{env.kphp_build_dir}} && dpkg -i kphp_1.0.1_amd64.deb"

- name: Compile dummy script
run: docker exec kphp-build-container-${{matrix.os}} bash -c
"cd ${{env.kphp_build_dir}} && kphp demo.php && kphp_out/server -o --user kitten"

- name: Remove docker container
run: docker rm -f kphp-build-container-${{matrix.os}}

# install-linux:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# include:
# - os: buster
# - os: focal
# - os: jammy

# steps:
# - uses: actions/checkout@v3

# - name: Build and start Docker container
# run: |
# docker build -f $GITHUB_WORKSPACE/.github/workflows/Dockerfile.${{matrix.os}}.install $GITHUB_WORKSPACE -t kphp-build-img-${{matrix.os}}-install
# docker run -dt --name kphp-build-container-${{matrix.os}}-install kphp-build-img-${{matrix.os}}-install

- name: Run php dummy script
run: docker exec -u kitten kphp-build-container-${{matrix.os}}-install bash -c
"cd ${{env.demo_dir}} && echo 'hello world' > demo.php && kphp --mode=cli --cxx=g++ demo.php && ./kphp_out/cli -o --user kitten"
# - name: Run php dummy script
# run: docker exec -u kitten kphp-build-container-${{matrix.os}}-install bash -c
# "cd ${{env.demo_dir}} && echo 'hello world' > demo.php && kphp --mode=cli --cxx=g++ demo.php && ./kphp_out/cli -o --user kitten"

# build-macos:
# runs-on: ${{matrix.os}}-12
Expand Down
24 changes: 21 additions & 3 deletions .github/workflows/Dockerfile.jammy.install
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,26 @@ RUN apt install -y software-properties-common && apt update && \
add-apt-repository ppa:ondrej/php -y && \
apt update

RUN apt install -y git cmake make g++ lld gperf netcat php7.4-vkext kphp vk-tl-tools && \
mkdir -p /var/www/vkontakte/data/www/vkontakte.com/tl/ && \
tl-compiler -e /var/www/vkontakte/data/www/vkontakte.com/tl/scheme.tlo /usr/share/vkontakte/examples/tl-files/common.tl /usr/share/vkontakte/examples/tl-files/tl.tl
# RUN apt install -y git cmake make g++ lld gperf netcat php7.4-vkext kphp vk-tl-tools && \
# mkdir -p /var/www/vkontakte/data/www/vkontakte.com/tl/ && \
# tl-compiler -e /var/www/vkontakte/data/www/vkontakte.com/tl/scheme.tlo /usr/share/vkontakte/examples/tl-files/common.tl /usr/share/vkontakte/examples/tl-files/tl.tl

RUN apt update && \
apt install -y git cmake make g++ lld gperf netcat build-essential binutils lintian debhelper dh-make devscripts

RUN apt-cache search kphp-test

RUN export DEBEMAIL="[email protected]"
RUN export DEBFULLNAME="Andrey Arutiunian"

RUN dh_make

RUN ls

RUN cd debian && cat control && cat copyright && cat rules

RUN dpkg-buildpackage

RUN dpkg -i

RUN useradd -ms /bin/bash kitten

0 comments on commit f32ab64

Please sign in to comment.