forked from theforeman/foreman_virt_who_configure
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add github action using docker (theforeman#175)
- Loading branch information
Showing
7 changed files
with
203 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
name: 'Build local dockerfile' | ||
description: 'Builds local dockerfile and runs the defailt action' | ||
runs: | ||
using: 'docker' | ||
image: '../images/Dockerfile' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
FROM quay.io/centos/centos:stream8 AS base | ||
|
||
ENV PGHOST=postgres | ||
ENV PGUSER=foreman | ||
ENV PGPASS=foreman | ||
ENV RAILS_ENV=test | ||
ENV GIT_COMMITTER_NAME="gh_actions" | ||
ENV GIT_COMMITTER_EMAIL="gh_actions@foreman_virt_who_configure.foreman" | ||
ENV WORKDIR=/projects/foreman | ||
ENV BUNDLE_PATH=vendor/bundle | ||
|
||
RUN \ | ||
dnf module install -y ruby:2.7 postgresql:12;\ | ||
dnf install -y epel-release; \ | ||
dnf install -y redhat-rpm-config libpq-devel ruby-devel systemd-devel make tar libvirt-devel zlib-devel libxml2-devel openssl-libs libvirt-devel nodejs automake gcc gcc-c++ kernel-devel libcurl-devel sqlite-devel git postgresql-server-devel; \ | ||
git config --global user.name $GIT_COMMITTER_NAME; \ | ||
git config --global user.email $GIT_COMMITTER_EMAIL; \ | ||
mkdir /projects; \ | ||
cd /projects; \ | ||
git clone --depth 1 --branch 3.8-stable https://github.com/theforeman/foreman.git; \ | ||
git clone --depth 1 --branch master https://github.com/theforeman/foreman_virt_who_configure.git | ||
|
||
RUN \ | ||
cd /projects/foreman; \ | ||
echo "gemspec :path => '../foreman_virt_who_configure', :development_group => :dev" > bundler.d/foreman_virt_who_configure.local.rb; \ | ||
cp ../foreman_virt_who_configure/config/database.yml.example config/database.yml; \ | ||
cp ../foreman_virt_who_configure/config/Gemfile.lock.gh_test Gemfile.lock; | ||
|
||
WORKDIR /projects/foreman | ||
RUN \ | ||
bundle config path vendor/bundle; \ | ||
|
||
RUN \ | ||
cd /projects/foreman; \ | ||
rm -rf Gemfile.lock; \ | ||
bundle install --jobs=3 --retry=3 --without journald development console | ||
|
||
COPY ./entrypoint.sh /usr/bin/ | ||
|
||
RUN sed -i s/SCLS=/SCLS=\""$SCLS"\"/g /usr/bin/entrypoint.sh | ||
|
||
RUN chmod +x /usr/bin/entrypoint.sh | ||
|
||
COPY ./run_tests.sh /usr/bin/ | ||
RUN chmod +x /usr/bin/run_tests.sh | ||
|
||
CMD ["/usr/bin/run_tests.sh"] | ||
|
||
ENTRYPOINT ["entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# version: "3" | ||
services: | ||
postgres: | ||
image: quay.io/jomitsch/postgres-with-evr | ||
ports: ['5432:5432'] | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
env: | ||
POSTGRES_USER: foreman | ||
POSTGRES_PASSWORD: foreman | ||
foreman: | ||
image: quay.io/shimshtein/tfm_plugin_test:foreman_2_5 | ||
volumes: | ||
- ../../:/projects/foreman_virt_who_configure:Z | ||
depends_on: | ||
- "postgres" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
export PATH=~/bin:${GEM_HOME}/bin:${PATH} | ||
|
||
SCLS= | ||
|
||
if [ -x "$(command -v scl_source)" ]; then | ||
source scl_source enable $SCLS | ||
fi | ||
|
||
cd $WORKDIR | ||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
|
||
bundle install | ||
|
||
# wait for postgres | ||
until PGPASSWORD=$PGPASS psql -h "$PGHOST" -U $PGUSER -c '\q'; do | ||
>&2 echo "Postgres is unavailable - sleeping" | ||
sleep 2 | ||
done | ||
|
||
if [ "$( psql -tAc "SELECT 1 FROM pg_database WHERE datname='foreman-test'" )" = '1' ] | ||
then | ||
echo "Database already exists" | ||
else | ||
bundle exec rails db:create | ||
fi | ||
|
||
if [ "$( psql -tAc "SELECT 1 FROM pg_database WHERE datname='foreman-prod'" )" = '1' ] | ||
then | ||
echo "Database already exists" | ||
else | ||
bundle exec rails db:create RAILS_ENV=production | ||
fi | ||
|
||
bundle exec rails db:migrate | ||
|
||
set -e | ||
|
||
# bundle exec rake foreman_virt_who_configure:rubocop | ||
bundle exec rake test:foreman_virt_who_configure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Build container for PR | ||
on: | ||
pull_request: | ||
paths: | ||
- '**/.github/**/*' | ||
jobs: | ||
build_test_container: | ||
runs-on: ubuntu-latest | ||
|
||
services: | ||
postgres: | ||
image: quay.io/jomitsch/postgres-with-evr | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
env: | ||
POSTGRES_USER: foreman | ||
POSTGRES_PASSWORD: foreman | ||
|
||
steps: | ||
- name: Checkout the repo | ||
uses: actions/checkout@v2 | ||
- name: Build local dockerfile | ||
uses: ./.github/actions/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Ruby tests | ||
on: | ||
push: | ||
branches: [master] | ||
paths-ignore: | ||
- '**/.github/**/*' | ||
pull_request: | ||
branches: [master] | ||
paths-ignore: | ||
- '**/.github/**/*' | ||
|
||
defaults: | ||
run: | ||
working-directory: /projects/foreman | ||
|
||
jobs: | ||
test_ruby: | ||
defaults: | ||
run: | ||
working-directory: /projects/foreman | ||
env: | ||
PGHOST: postgres | ||
PGUSER: foreman | ||
PGPASS: foreman | ||
RAILS_ENV: test | ||
host: postgres | ||
WORKDIR: /projects/foreman | ||
BUNDLE_PATH: vendor/bundle | ||
GIT_COMMITTER_NAME: "gh_actions" | ||
GIT_COMMITTER_EMAIL: "gh_actions@virt_who_configure.foreman" | ||
|
||
runs-on: ubuntu-latest | ||
container: | ||
image: ghcr.io/theforeman/tfm_plugin_test:foreman_3_7 | ||
|
||
services: | ||
postgres: | ||
image: quay.io/jomitsch/postgres-with-evr | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
env: | ||
POSTGRES_USER: foreman | ||
POSTGRES_PASSWORD: foreman | ||
|
||
steps: | ||
- name: Checkout foreman_virt_who_configure repo | ||
uses: actions/checkout@v2 | ||
with: | ||
path: ${{ github.workspace }}/projects/foreman_virt_who_configure | ||
- name: Fix git config | ||
run: | | ||
rm -rf /projects/foreman_virt_who_configure/{app,test,lib} | ||
cp -Rf $GITHUB_WORKSPACE/projects/foreman_virt_who_configure /projects/ | ||
cd /projects/foreman | ||
/usr/bin/entrypoint.sh git config --global user.name $GIT_COMMITTER_NAME | ||
/usr/bin/entrypoint.sh git config --global user.email $GIT_COMMITTER_EMAIL | ||
- name: Run tests suite | ||
run: | | ||
cd /projects/foreman | ||
/usr/bin/entrypoint.sh /usr/bin/run_tests.sh |