diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d62434b..2717c7b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,19 +36,134 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - - name: Install requirements + - name: Install uv + run: curl -LsSf https://astral.sh/uv/install.sh | sh + + - name: Install dependencies run: | - cd src/ - pip install -r requirements.txt + export PATH="$HOME/.local/bin:$PATH" + uv sync --group dev - name: Run tests run: | - cd src/ - pytest -s tests/ -vv + export PATH="$HOME/.local/bin:$PATH" + uv run pytest -s tests/ -vv + + Tests-E2E-Docker: + runs-on: ubuntu-latest + timeout-minutes: 20 + needs: [Test] + permissions: + contents: read + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install uv + run: curl -LsSf https://astral.sh/uv/install.sh | sh + + - name: Install dependencies + run: | + export PATH="$HOME/.local/bin:$PATH" + uv sync --group dev + + - name: Run Docker Compose E2E tests + run: | + export PATH="$HOME/.local/bin:$PATH" + uv run pytest tests_e2e/test_docker_compose.py -sv --tb=short + + Tests-E2E-Kubernetes: + runs-on: ubuntu-latest + timeout-minutes: 30 + needs: [Test] + permissions: + contents: read + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install uv + run: curl -LsSf https://astral.sh/uv/install.sh | sh + + - name: Install dependencies + run: | + export PATH="$HOME/.local/bin:$PATH" + uv sync --group dev + + - name: Run Kubernetes E2E tests + run: | + export PATH="$HOME/.local/bin:$PATH" + uv run pytest tests_e2e/test_kubernetes.py -sv --tb=short + + Tests-E2E-Additional: + runs-on: ubuntu-latest + needs: [Test] + timeout-minutes: 20 + permissions: + contents: read + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install uv + run: curl -LsSf https://astral.sh/uv/install.sh | sh + + - name: Install dependencies + run: | + export PATH="$HOME/.local/bin:$PATH" + uv sync --group dev + + - name: Clean Docker build cache + run: docker builder prune -af + + - name: Run Static E2E tests + run: | + export PATH="$HOME/.local/bin:$PATH" + uv run pytest tests_e2e/test_static.py -sv --tb=short + + - name: Run Proxy Headers E2E tests + run: | + export PATH="$HOME/.local/bin:$PATH" + uv run pytest tests_e2e/test_proxy_headers.py -sv --tb=short + + Tests-E2E-Swarm: + runs-on: ubuntu-latest + timeout-minutes: 30 + needs: [Test] + permissions: + contents: read + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install uv + run: curl -LsSf https://astral.sh/uv/install.sh | sh + + - name: Install dependencies + run: | + export PATH="$HOME/.local/bin:$PATH" + uv sync --group dev + + - name: Clean Docker build cache + run: docker builder prune -af + + - name: Build Docker image + env: + DOCKER_BUILDKIT: "0" + run: docker build -t byjg/easy-haproxy:local -f deploy/docker/Dockerfile . + + - name: Run Swarm E2E tests + run: | + export PATH="$HOME/.local/bin:$PATH" + uv run pytest tests_e2e/test_swarm.py -sv --tb=short Build: runs-on: ubuntu-latest - needs: Test + needs: [Test, Tests-E2E-Docker, Tests-E2E-Kubernetes, Tests-E2E-Additional, Tests-E2E-Swarm] permissions: contents: read packages: write @@ -64,7 +179,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Log into registry - if: github.event_name != 'pull_request' || github.event.inputs.push == 'true' + if: github.event_name == 'push' || github.event.inputs.push == 'true' uses: docker/login-action@v3 with: registry: ${{ secrets.DOCKER_REGISTRY }} @@ -127,11 +242,11 @@ jobs: uses: docker/build-push-action@v5 with: context: . - file: build/Dockerfile + file: deploy/docker/Dockerfile build-args: | RELEASE_VERSION_ARG="${{ steps.tags.outputs.result }}" platforms: linux/amd64,linux/arm64 - push: ${{ github.event_name != 'pull_request' || github.event.inputs.push == 'true' }} + push: ${{ github.event_name == 'push' || github.event.inputs.push == 'true' }} tags: ${{ steps.normalized.outputs.result }} labels: ${{ steps.meta.outputs.labels }} @@ -140,12 +255,35 @@ jobs: # - name: Docker Hub Description - # if: github.event_name != 'pull_request' || github.event.inputs.push == 'true' + # if: github.event_name == 'push' || github.event.inputs.push == 'true' # run: | # wget -q https://github.com/christian-korneck/docker-pushrm/releases/download/v1.8.0/docker-pushrm_linux_amd64 -O $HOME/.docker/cli-plugins/docker-pushrm # chmod +x $HOME/.docker/cli-plugins/docker-pushrm # docker pushrm ${{ env.IMAGE_NAME }} + Publish-PyPI: + runs-on: ubuntu-latest + needs: [Test, Tests-E2E-Docker, Tests-E2E-Kubernetes, Tests-E2E-Additional, Tests-E2E-Swarm] + if: startsWith(github.ref, 'refs/tags/') + permissions: + contents: read + id-token: write # Required for OIDC trusted publisher + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install uv + run: curl -LsSf https://astral.sh/uv/install.sh | sh + + - name: Build package + run: | + export PATH="$HOME/.local/bin:$PATH" + uv build + + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + Helm: runs-on: 'ubuntu-latest' needs: Build @@ -191,4 +329,5 @@ jobs: with: folder: devops project: ${{ github.event.repository.name }} - secrets: inherit + secrets: + DOC_TOKEN: ${{ secrets.DOC_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index a32f7e6..19f6f44 100644 --- a/.gitignore +++ b/.gitignore @@ -6,12 +6,21 @@ __pycache__ .pytest_cache *.pyc .env -/examples/static/conf/config.yml -/examples/docker/certs/haproxy/.place_holder_cert.pem -/examples/static/host1.local.pem -/examples/swarm/certs/host1.local.pem -/examples/docker/host2.local.pem -/examples/swarm/certs/host2.local.pem -/examples/docker/jwt_private.pem -/examples/docker/jwt_pubkey.pem -/examples/docker/cloudflare_ips.lst + +# uv +.venv/ + +# Build artifacts +dist/ +*.egg-info/ + +/tests_e2e/static/conf/config.yml +/tests_e2e/docker/certs/haproxy/.place_holder_cert.pem +/tests_e2e/static/host1.local.pem +/tests_e2e/swarm/certs/host1.local.pem +/tests_e2e/docker/host2.local.pem +/tests_e2e/swarm/certs/host2.local.pem +/tests_e2e/docker/jwt_private.pem +/tests_e2e/docker/jwt_pubkey.pem +/tests_e2e/docker/cloudflare_ips.lst +/tests_e2e/docker/pebble-ca.pem diff --git a/.gitpod.yml b/.gitpod.yml deleted file mode 100644 index b763650..0000000 --- a/.gitpod.yml +++ /dev/null @@ -1,9 +0,0 @@ -# This configuration file was automatically generated by Gitpod. -# Please adjust to your needs (see https://www.gitpod.io/docs/config-gitpod-file) -# and commit this file to your remote git repository to share the goodness with others. - -tasks: - - command: | - virtualenv -p /usr/bin/python3 venv - source venv/bin/activate - pip install -r src/requirements.txt diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..e4fba21 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.12 diff --git a/.run/pytest in tests.run.xml b/.run/pytest in tests.run.xml index 9b5784c..c72dc30 100644 --- a/.run/pytest in tests.run.xml +++ b/.run/pytest in tests.run.xml @@ -5,16 +5,17 @@