From 88cff26c93b93e409a4f0141a9a9f9fc9cd64fc0 Mon Sep 17 00:00:00 2001 From: Ross Smith Date: Thu, 1 Feb 2024 11:40:09 +0000 Subject: [PATCH] Simple CI for Pull Requests (#247) * Basic CI on PR * Add workflow dispatch whilst testing * Remove status action * Filter for push * Add single ci target * Restrictive permissions --- .github/workflows/ci.yml | 34 ++++++++++++++++++++++++++++++++++ Makefile | 27 +++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 Makefile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..bc40e65ef --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,34 @@ +name: CI + +on: + pull_request: + push: + branches: + - main + +permissions: + contents: read + packages: write + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Pre-build image and run make in dev container + uses: devcontainers/ci@v0.3 + with: + imageName: ghcr.io/azure-samples/chat-with-your-data-solution-accelerator + cacheFrom: ghcr.io/azure-samples/chat-with-your-data-solution-accelerator + runCmd: make ci + refFilterForPush: refs/heads/main diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..22015f8b5 --- /dev/null +++ b/Makefile @@ -0,0 +1,27 @@ +SHELL := /bin/bash + +.PHONY: help +.DEFAULT_GOAL := help + +ENV_FILE := .env +ifeq ($(filter $(MAKECMDGOALS),config clean),) + ifneq ($(strip $(wildcard $(ENV_FILE))),) + ifneq ($(MAKECMDGOALS),config) + include $(ENV_FILE) + export + endif + endif +endif + +help: ## ๐Ÿ’ฌ This help message :) + @grep -E '[a-zA-Z_-]+:.*?## .*$$' $(firstword $(MAKEFILE_LIST)) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-23s\033[0m %s\n", $$1, $$2}' + +ci: unittest build-frontend ## ๐Ÿš€ Continuous Integration (called by Github Actions) + +unittest: ## ๐Ÿงช Run the unit tests + @echo -e "\e[34m$@\e[0m" || true + @python -m pytest -m "not azure" + +build-frontend: ## ๐Ÿ—๏ธ Build the Frontend webapp + @echo -e "\e[34m$@\e[0m" || true + @cd code/app/frontend && npm install && npm run build