Skip to content

Commit

Permalink
Merge pull request #42 from brettt89/feature/new-builds
Browse files Browse the repository at this point in the history
Add FPM and CLI builds
  • Loading branch information
brettt89 authored Aug 9, 2020
2 parents 86a99a5 + 3230397 commit 835188f
Show file tree
Hide file tree
Showing 34 changed files with 428 additions and 1,403 deletions.
71 changes: 28 additions & 43 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
pull_request:
branches:
- master
- release/**
# Also trigger on page_build, as well as release created events
page_build:
release:
Expand All @@ -19,14 +20,13 @@ jobs:
name: Build & Test
# This job runs on Linux
runs-on: ubuntu-latest
env:
distro: apache
strategy:
fail-fast: false
matrix:
os: [stretch, buster]
php: [7.2, 7.3, 7.4]
framework: [3, 4]
distro: [apache, fpm, cli]
exclude:
- os: stretch
php: 7.4
Expand All @@ -39,20 +39,10 @@ jobs:
uses: actions/checkout@v2

- name: Pull Docker images
run: docker-compose -f docker-compose.test.yml pull
run: docker-compose pull

- name: Docker Caching
uses: satackey/[email protected]
with:
key: docker-cache-v2-${{ matrix.php }}-${{ env.distro }}-${{ matrix.os }}-{hash}
restore-keys: |
docker-cache-v2-${{ matrix.php }}-${{ env.distro }}-${{ matrix.os }}-
- name: Build Images
env:
BUILD_DIR: ./src/${{ matrix.php }}/${{ env.distro }}/${{ matrix.os }}
IMAGE: brettt89/silverstripe-web:${{ matrix.php }}-${{ env.distro }}-${{ matrix.os }}
run: docker-compose -f docker-compose.test.yml build
- name: Build Image
run: ./build/build-image.sh ${{ matrix.php }}-${{ matrix.distro }}-${{ matrix.os }}

- name: Get Composer Cache Directory
id: composer-data
Expand All @@ -71,33 +61,35 @@ jobs:
env:
FRAMEWORK: ${{ matrix.framework }}
COMPOSER_HOME: ${{ steps.composer-data.outputs.dir }}
run: docker-compose -f docker-compose.test.yml run create-project
run: docker-compose run create-project

- name: Install Silverstripe test project
env:
COMPOSER_HOME: ${{ steps.composer-data.outputs.dir }}
run: docker-compose -f docker-compose.test.yml run install-project
run: docker-compose run install-project

- name: Run tests
env:
BUILD_DIR: ./src/${{ matrix.php }}/${{ env.distro }}/${{ matrix.os }}
IMAGE: brettt89/silverstripe-web:${{ matrix.php }}-${{ env.distro }}-${{ matrix.os }}
DISTRO: ${{ env.distro }}
run: docker-compose -f docker-compose.test.yml run sut
TAG: ${{ matrix.php }}-${{ matrix.distro }}-${{ matrix.os }}
run: docker-compose run sut

- name: The job has failed
if: ${{ failure() }}
run: |
docker-compose logs
# Legacy PHP 5.6 and 7.1 tests
build_legacy:
# Job name is Greeting
name: Legacy Build & Test
# This job runs on Linux
runs-on: ubuntu-latest
env:
distro: apache
strategy:
matrix:
os: [jessie, stretch, buster]
php: [5.6, 7.1]
framework: [3, 4]
distro: [apache, fpm, cli]
exclude:
- os: buster
php: 5.6
Expand All @@ -108,20 +100,10 @@ jobs:
uses: actions/checkout@v2

- name: Pull Docker images
run: docker-compose -f docker-compose.test.yml pull
run: docker-compose pull

- name: Docker Caching
uses: satackey/[email protected]
with:
key: docker-cache-v2-${{ matrix.php }}-${{ env.distro }}-${{ matrix.os }}-{hash}
restore-keys: |
docker-cache-v2-${{ matrix.php }}-${{ env.distro }}-${{ matrix.os }}-
- name: Build Images
env:
BUILD_DIR: ./src/${{ matrix.php }}/${{ env.distro }}/${{ matrix.os }}
IMAGE: brettt89/silverstripe-web:${{ matrix.php }}-${{ env.distro }}-${{ matrix.os }}
run: docker-compose -f docker-compose.test.yml build
- name: Build Image
run: ./build/build-image.sh ${{ matrix.php }}-${{ matrix.distro }}-${{ matrix.os }}

- name: Get Composer Cache Directory
id: composer-data
Expand All @@ -134,22 +116,25 @@ jobs:
path: ${{ steps.composer-data.outputs.dir }}
key: ${{ runner.os }}-composer-${{ matrix.framework }}-${{ matrix.php }}
restore-keys: |
${{ runner.os }}-composer-${{ matrix.framework }}
${{ runner.os }}-composer-${{ matrix.framework }}-
- name: Create Silverstripe ${{ matrix.framework }} test project
env:
FRAMEWORK: ${{ matrix.framework }}
COMPOSER_HOME: ${{ steps.composer-data.outputs.dir }}
run: docker-compose -f docker-compose.test.yml run create-project
run: docker-compose run create-project

- name: Install Silverstripe test project
env:
COMPOSER_HOME: ${{ steps.composer-data.outputs.dir }}
run: docker-compose -f docker-compose.test.yml run install-project
run: docker-compose run install-project

- name: Run tests
env:
BUILD_DIR: ./src/${{ matrix.php }}/${{ env.distro }}/${{ matrix.os }}
IMAGE: brettt89/silverstripe-web:${{ matrix.php }}-${{ env.distro }}-${{ matrix.os }}
DISTRO: ${{ env.distro }}
run: docker-compose -f docker-compose.test.yml run sut
TAG: ${{ matrix.php }}-${{ matrix.distro }}-${{ matrix.os }}
run: docker-compose run sut

- name: The job has failed
if: ${{ failure() }}
run: |
docker-compose logs
115 changes: 0 additions & 115 deletions .travis.yml.bak

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2017 Brett Tasker
Copyright (c) 2020 Brett Tasker

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
64 changes: 56 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,66 @@
export LOG_LEVEL := $(findstring s,$(word 1, $(MAKEFLAGS)))
ARG=$(filter-out $@,$(MAKECMDGOALS))
ARG = $(filter-out $@,$(MAKECMDGOALS))
TAG = $(if $(filter %,$(ARG)),$(ARG),7.4-apache-buster)

.PHONY: all build clean $(ARG)
ifndef FRAMEWORK
FRAMEWORK = 4
endif

.PHONY: all build build-image new-test create-project install-project test-build-image test clean $(ARG)
all:
@echo "Silverstripe Web - Docker image"
@echo "Silverstripe Web - Docker image builder"
@echo
@echo "Basic Commands"
@echo " build <regex> Build and tag all images. Filter using <regex> on tag structure."
@echo " e.g. "7.4" for php7.4 builds, or "buster" for all buster builds."
@echo " clean Delete all image tags / cache using."
@echo " build <regex> Build and tag all images. Filter using <regex> on tag structure."
@echo " build-image <tag> Build and tag specific image."
@echo
@echo "Test Commands"
@echo " new-test <tag> Start a new test using <tag>, Default: 7.4-apache-buster."
@echo " test <tag> Execute tests, assumes project has been build."
@echo " clean Delete all test data."
@echo
@echo "Advanced Test Commands"
@echo " create-project <tag> Create new Silverstripe Project".
@echo " Environment variable FRAMEWORK=3 to change version"
@echo " install-project <tag> Install project dependancies"
@echo " test-build-image <tag> Test the image has been built locally"
@echo " build-test Build 'sut' test image, used for running tests"
@echo
@echo "Parameters"
@echo " <regex> Regex for matching against tag. e.g. '7.4'"
@echo " <tag> Tag to build/test. e.g. '5.6-apache-jessie'"

build:
@./build.sh $(filter-out $@,$(MAKECMDGOALS))
./build/build-regex.sh $(ARG)

build-image:
./build/build-image.sh $(TAG)

new-test:
@echo "Running new test"
@echo " Tag: $(TAG)"
@echo
@$(MAKE) --quiet clean
@$(MAKE) --quiet build-image $(TAG)
@$(MAKE) --quiet test-build-image $(TAG)
@FRAMEWORK=$(FRAMEWORK) $(MAKE) --quiet create-project $(TAG)
@$(MAKE) --quiet install-project $(TAG)
@$(MAKE) --quiet test $(TAG)

create-project:
TAG=$(TAG) FRAMEWORK=$(FRAMEWORK) docker-compose run create-project

install-project:
TAG=$(TAG) docker-compose run install-project

test-build-image:
TAG=${TAG} docker-compose build

build-test:
TAG=$(TAG) docker-compose build sut

test:
TAG=$(TAG) docker-compose run sut

clean:
@docker rmi $(docker images | grep 'silversripe-web') $a
docker-compose down --volume
Loading

0 comments on commit 835188f

Please sign in to comment.