Skip to content

Commit

Permalink
feat(backup): add backup img ci for e2e tests, docker build and push (#…
Browse files Browse the repository at this point in the history
…795)

also fix the current CI
  • Loading branch information
brokenpip3 committed Mar 6, 2023
1 parent e9fbe57 commit d91a729
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 9 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy-nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ jobs:
- name: Login to Quay.io
uses: docker/login-action@v1
with:
registry: quay.io
username: ${{ secrets.QUAYIO_USERNAME }}
password: ${{ secrets.QUAYIO_TOKEN }}

Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/release-backup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Release Backup Pvc
on:
workflow_dispatch:
pull_request:
types: [edited, opened, reopened, synchronize]
paths:
- 'backup/pvc/**'

push:
branches: ["master"]
tags: ["*"]
paths:
- 'backup/pvc/**'

jobs:
build-and-release-backup:
name: Release Backup Pvc, build, bump and push new image
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Build the e2e image
run: make -C backup/pvc docker-build-e2e

- name: Run the e2e tests
run: make -C backup/pvc docker-e2e

- name: Configure Git
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request'
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Bump the version
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request'
run: make -C backup/pvc sembump && make -C backup/pvc bump-version

- name: Login to Quay.io
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: quay.io
username: ${{ secrets.QUAYIO_USERNAME }}
password: ${{ secrets.QUAYIO_TOKEN }}

- name: Build and push the image to DockerHub
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request'
run: |
git reset --hard
make -C backup/pvc docker-build
make -C backup/pvc docker-release
1 change: 1 addition & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
- name: Login to Quay.io
uses: docker/login-action@v1
with:
registry: quay.io
username: ${{ secrets.QUAYIO_USERNAME }}
password: ${{ secrets.QUAYIO_TOKEN }}

Expand Down
31 changes: 23 additions & 8 deletions backup/pvc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
GITCOMMIT := $(shell git rev-parse --short HEAD)
GITBRANCH := $(shell git rev-parse --abbrev-ref HEAD)
GITUNTRACKEDCHANGES := $(shell git status --porcelain --untracked-files=no)
GITIGNOREDBUTTRACKEDCHANGES := $(shell git ls-files -i --exclude-standard)
GITIGNOREDBUTTRACKEDCHANGES := $(shell git ls-files -i -o --exclude-standard)
ifneq ($(GITUNTRACKEDCHANGES),)
GITCOMMIT := $(GITCOMMIT)-dirty
endif
Expand Down Expand Up @@ -58,7 +58,7 @@ spring-clean: ## Cleanup git ignored files (interactive)
git clean -Xdi

.PHONY: checkmake
HAS_CHECKMAKE := $(shell which checkmake)
HAS_CHECKMAKE := $(shell command -v checkmake)
checkmake: ## Check this Makefile
@echo "+ $@"
ifndef HAS_CHECKMAKE
Expand All @@ -68,23 +68,28 @@ endif

define e2e
echo "\nRunning $(1) e2e test";
@e2e/$(1)/test.sh $(QUAY_REGISTRY)-$(NAME):$(GITCOMMIT)
@e2e/$(1)/test.sh quay.io/$(QUAY_REGISTRY)-$(NAME):$(GITCOMMIT)
endef

.PHONY: docker-e2e
E2E_TESTS := $(shell ls e2e)
docker-e2e: docker-build ## Make e2e tests for docker image
docker-e2e: docker-build-e2e ## Make e2e tests for docker image
@echo "+ $@"
$(foreach TEST_NAME,$(E2E_TESTS), $(call e2e,$(TEST_NAME)))

.PHONY: docker-login
docker-login: ## Log in into the Docker repository
@echo "+ $@"

.PHONY: docker-build-e2e
docker-build-e2e: UID=1001
docker-build-e2e: GID=1001
docker-build-e2e: docker-build

.PHONY: docker-build
docker-build: check-env ## Build the container
@echo "+ $@"
docker build . --build-arg UID=$(UID) --build-arg GID=$(GID) -t $(QUAY_REGISTRY)-$(NAME):$(GITCOMMIT) --file Dockerfile
docker build . --build-arg UID=$(UID) --build-arg GID=$(GID) -t quay.io/$(QUAY_REGISTRY)-$(NAME):$(GITCOMMIT) --file Dockerfile

.PHONY: docker-images
docker-images: ## List all local containers
Expand Down Expand Up @@ -127,15 +132,25 @@ docker-run: docker-build ## Run the container in docker, you can use EXTRA_ARGS
docker run --rm -i $(DOCKER_FLAGS) \
$(QUAY_REGISTRY)-$(NAME):$(GITCOMMIT) $(ARGS)

.PHONY: sembump
HAS_SEMBUMP := $(shell which $(PROJECT_DIR)/bin/sembump)
sembump: # Download sembump locally if necessary
@echo "+ $@"
ifndef HAS_SEMBUMP
mkdir -p $(PROJECT_DIR)/bin
wget -O $(PROJECT_DIR)/bin/sembump https://github.com/justintout/sembump/releases/download/v0.1.0/sembump-linux-amd64
chmod +x $(PROJECT_DIR)/bin/sembump
endif

.PHONY: bump-version
BUMP := patch
bump-version: ## Bump the version in the version file. Set BUMP to [ patch | major | minor ]
bump-version: sembump ## Bump the version in the version file. Set BUMP to [ patch | major | minor ]
@echo "+ $@"
$(eval NEW_VERSION=$(shell $(PROJECT_DIR)/../../bin/sembump --kind $(BUMP) $(VERSION)))
@echo "Bumping VERSION.txt from $(VERSION) to $(NEW_VERSION)"
echo $(NEW_VERSION) > VERSION.txt
git add VERSION.txt
git commit -vaem "Bump backup PVC version to $(NEW_VERSION)"
git commit -avm "Bump backup PVC version to $(NEW_VERSION)"

.PHONY: tag
tag: ## Create a new git tag to prepare to build a release
Expand All @@ -159,7 +174,7 @@ ifneq ($(GITUNTRACKEDCHANGES),)
endif
ifneq ($(GITIGNOREDBUTTRACKEDCHANGES),)
@echo "Ignored but tracked files:"
@git ls-files -i --exclude-standard
@git ls-files -i -c --exclude-standard
@echo
endif
@echo "Dependencies:"
Expand Down
2 changes: 1 addition & 1 deletion backup/pvc/config.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Setup variables for the Makefile
NAME=pvc
QUAY_ORGANIZATION=jenkins-kubernetes-operator
QUAY_REGISTRY=backup-pvc
QUAY_REGISTRY=backup
UID=1000
GID=1000

0 comments on commit d91a729

Please sign in to comment.