Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to github #1

Merged
merged 12 commits into from
Apr 10, 2024
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
178 changes: 178 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
name: Piler build

on:
push:
branches:
- master

pull_request:
types:
- opened # PR created
- synchronize # commit pushed to PR
- reopened # closed PR reopened
branches:
- master

env:
BUILDER_IMAGE: sutoj/builder:0.1
IMAGE_NAME: sutoj/piler
DISTRO: jammy
PROJECT_ID: piler
ARCH: amd64
CONTAINER: piler
RT: 1

jobs:
build:
runs-on: ubuntu-latest

outputs:
IMAGE_TAG: ${{ steps.generate-version.outputs.IMAGE_TAG }}
VERSION: ${{ steps.generate-version.outputs.VERSION }}
PACKAGE: ${{ steps.build-package.outputs.PACKAGE }}

steps:
- uses: actions/checkout@v4

- name: Set version tag
id: generate-version
run: |
read -r VERSION < VERSION
COMMIT_ID="$( git rev-parse --short HEAD )"
IMAGE_TAG="${VERSION}-${COMMIT_ID}"

echo "image tag: $IMAGE_TAG"
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_OUTPUT
echo "COMMIT_ID=$COMMIT_ID" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
shell: bash

- name: Build package
id: build-package
run: |
docker run --rm -e PROJECT_ID -e DISTRO -e ARCH -e VERSION -e COMMIT_ID -e BUILD_NUMBER=$GITHUB_RUN_ID -v $PWD:/repo -v $PWD/docker:/data ${{ env.BUILDER_IMAGE }}
ls -la docker
a="$(ls docker/*deb)"
PACKAGE="${a##*/}"
echo "PACKAGE=$PACKAGE" >> $GITHUB_OUTPUT
echo "PACKAGE=$PACKAGE" >> $GITHUB_ENV
echo "Package: ${PACKAGE}"
shell: bash

- name: Upload package
uses: actions/upload-artifact@v4
with:
name: package
path: docker/*deb
retention-days: 1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build test image
uses: docker/build-push-action@v5
with:
context: docker
push: true
tags: ${{ env.IMAGE_NAME }}:${{ env.VERSION }}
build-args: |
PACKAGE=${{ env.PACKAGE }}

run-tests:
runs-on:
- self-hosted
- X64

needs:
- build

steps:
- uses: actions/checkout@v4

- name: Destroy all containers
run: |
pushd docker
# Fix compose file
sed -i 's/^volumes:/ imap.aaa.fu:\n image: sutoj\/imap\n container_name: imap.aaa.fu\n\nvolumes:/' docker-compose.yaml
docker compose down -v || true
popd
shell: bash

- name: Start containers
run: |
export VERSION=${{ needs.build.outputs.VERSION }}
pushd docker
docker compose pull piler
docker compose up -d
i=0
while [[ "$(docker inspect -f '{{.State.Health.Status}}' "$CONTAINER")" != "healthy" ]]; do
i=$((i+1))
sleep 2
if [[ $i -gt 45 ]]; then
"sleep is still not running inside ${CONTAINER}"
exit 1
fi
done
docker compose ps
popd
shell: bash

- name: Remove stale images
run: yes|docker image prune

- name: Setup piler
run: |
./tests/setup.sh
shell: bash
env:
CONFIG_SITE_PHP: ${{ vars.CONFIG_SITE_PHP }}

- name: Run tests
run: |
./tests/run.sh
shell: bash

publish-docker-image:
if: github.ref_name == 'master'

runs-on:
- self-hosted
- X64

needs:
- build
- run-tests

steps:
- uses: actions/checkout@v4

- name: Download package
uses: actions/download-artifact@v4
with:
name: package
path: docker

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v5
with:
context: docker
push: true
tags: ${{ env.IMAGE_NAME }}:${{ needs.build.outputs.VERSION }}
build-args: |
PACKAGE=${{ needs.build.outputs.PACKAGE }}
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @jsuto
22 changes: 0 additions & 22 deletions bitbucket-pipelines.yml

This file was deleted.

28 changes: 28 additions & 0 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM ubuntu:22.04

LABEL description="jammy builder container"
LABEL maintainer="Janos SUTO, sj@acts.hu"

ENV DEBIAN_FRONTEND="noninteractive"

SHELL ["/bin/bash", "-c", "-o", "pipefail"]

# hadolint ignore=DL3001,DL3008,DL3028
RUN apt-get update && \
apt-get install --no-install-recommends -y gnupg git jq curl unzip openssl openssh-client make gcc sysstat catdoc unrtf poppler-utils tnef libwrap0-dev libssl-dev libtre-dev libzip-dev libmariadb-dev libcurl4-openssl-dev ruby ruby-dev mariadb-server openjdk-8-jre phpunit \
php8.1-cli php8.1-cgi php8.1-mysql php8.1-fpm php8.1-zip php8.1-ldap php8.1-gd php8.1-curl php8.1-xml php8.1-memcached php8.1-mbstring php8.1-opcache && \
apt-get clean && rm -rf /var/lib/apt/lists/* && \
groupadd piler && useradd -g piler -s /bin/bash -d /var/piler piler && usermod -L piler && \
mkdir -p /var/piler && \
service mariadb start && \
echo "create database piler1 character set utf8mb4" | mysql && \
echo "grant all privileges on piler1.* to piler@localhost identified by 'piler123'" | mysql && \
gem install fpm && \
curl -L -o /usr/local/bin/mc https://dl.min.io/client/mc/release/linux-amd64/mc && \
chmod +x /usr/local/bin/mc && \
curl -L -o /tmp/composer.phar https://getcomposer.org/composer-stable.phar

COPY run.sh /run.sh
COPY piler.conf /etc/piler/piler.conf

CMD ["/run.sh"]
Loading