Skip to content

Commit

Permalink
feat: remove poetry (#132)
Browse files Browse the repository at this point in the history
* chore: update dependabot config

* chore: use requirements.txt file in splunk_sync.sh

* refactor: remove poetry for the main file

* chore: use Dockerfile to build the action

* ci: update pipeline to include pre-commit and permissions to push package

* style: pre-commit

* chore: update Python version in Dockerfile

* chore: update docker/build-push-action to v4
  • Loading branch information
artemrys authored May 24, 2023
1 parent 69112d8 commit 1d5064d
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 213 deletions.
11 changes: 5 additions & 6 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
target-branch: "main"
schedule:
interval: "daily"
interval: "weekly"
- package-ecosystem: "pip"
directory: "/"
target-branch: "main"
schedule:
interval: "daily"
- package-ecosystem: "docker" # See documentation for possible values
directory: "/" # Location of package manifests
interval: "weekly"
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "daily"
interval: "weekly"
41 changes: 21 additions & 20 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,33 @@ on:
- "develop"

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.7"
- uses: pre-commit/action@v3.0.0
build_action:
runs-on: ubuntu-latest
name: Build Action
needs: pre-commit
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/checkout@v3
with:
persist-credentials: false
- name: Install yq
run: sudo snap install yq
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Packages Docker Registry
uses: docker/login-action@v2
- run: sudo snap install yq
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: docker_action_meta
- id: docker_action_meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/splunk/addonfactory-test-matrix-action/addonfactory-test-matrix-action
Expand All @@ -63,21 +67,18 @@ jobs:
type=ref,event=pr
type=sha
type=sha,format=long
- name: Build and push action
id: docker_action_build
uses: docker/build-push-action@v3
- id: docker_action_build
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.docker_action_meta.outputs.tags }}
labels: ${{ steps.docker_action_meta.outputs.labels }}
cache-to: type=inline
- name: Semantic Release
uses: splunk/semantic-release-action@v1.2
- uses: splunk/semantic-release-action@v1.3
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_ADMIN }}
update-semver:
name: Move Respository semver tags
if: startsWith(github.ref, 'refs/tags/v')
needs: build_action
runs-on: ubuntu-latest
Expand Down
4 changes: 0 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,3 @@ repos:
rev: 22.6.0
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort
21 changes: 3 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,26 +1,11 @@
# Container image that runs your code
FROM python:3.10.5 as base
ENV PYTHONFAULTHANDLER=1 \
PYTHONHASHSEED=random \
PYTHONUNBUFFERED=1
FROM python:3.11.3

FROM base as builder
ENV PIP_DEFAULT_TIMEOUT=100 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_NO_CACHE_DIR=1 \
POETRY_VERSION=1.0.5

RUN pip install "poetry"
RUN python -m venv /venv
COPY pyproject.toml poetry.lock ./
RUN poetry export -f requirements.txt | pip install -r /dev/stdin
RUN . /venv/bin/activate
COPY . .
RUN poetry build && . /venv/bin/activate; pip install dist/*.whl

FROM base as final
RUN pip install -r requirements.txt

COPY /entrypoint.sh /
COPY --from=builder /venv /venv

WORKDIR /github/workspace
ENTRYPOINT ["/entrypoint.sh"]
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# action.yml
name: "Add n Factory test matrix"
name: "Add on factory test matrix"
description: "This tool automates the selection matrix dimensions"
runs:
using: "docker"
image: docker://ghcr.io/splunk/addonfactory-test-matrix-action/addonfactory-test-matrix-action:v1.8.32
image: Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,11 @@ def _generate_supported_vendors(args, path):
props[k] = value
if props.get("trigger_modinput_functional") is not False:
supported_modinput_functional_vendors.append(
{"version": props["version"],
"image": props["docker_image"]}
{"version": props["version"], "image": props["docker_image"]}
)
if props.get("trigger_ui") is not False:
supported_ui_vendors.append(
{"version": props["version"],
"image": props["docker_image"]}
{"version": props["version"], "image": props["docker_image"]}
)

return supported_modinput_functional_vendors, supported_ui_vendors
Expand Down Expand Up @@ -180,6 +178,9 @@ def main():
)
pprint.pprint(f"Supported UI Vendors {supported_ui_vendors}")
with open(os.environ["GITHUB_OUTPUT"], "a") as fh:
print(f"supportedModinputFunctionalVendors={json.dumps(supported_modinput_functional_vendors)}", file=fh)
print(
f"supportedModinputFunctionalVendors={json.dumps(supported_modinput_functional_vendors)}",
file=fh,
)
with open(os.environ["GITHUB_OUTPUT"], "a") as fh:
print(f"supportedUIVendors={json.dumps(supported_ui_vendors)}", file=fh)
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ if [ -f $INPUT_APP_PATH ]
then
f="--file=.addonmatrix"
fi
splunk-addon-matrix-gen $f $@
python /addonfactory_test_matrix_action/main.py $f $@
127 changes: 0 additions & 127 deletions poetry.lock

This file was deleted.

23 changes: 0 additions & 23 deletions pyproject.toml

This file was deleted.

2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
requests
packaging
1 change: 0 additions & 1 deletion sc4s_sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# echo all the commands
set -x

REPOORG=splunk
current_tag=$(cat config/SC4S_matrix.conf | grep -oP 'VERSION\s*=\s*([0-9\.]+)')
echo $current_tag
re='VERSION\s*=\s*([0-9.]+)'
Expand Down
7 changes: 1 addition & 6 deletions splunk_sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
# echo all the commands
set -x

REPOORG=splunk

pip install pip --upgrade
pip install poetry
poetry export --without-hashes --dev -o requirements_dev.txt
pip install -r requirements_dev.txt
pip install -r requirements.txt
splunk_version=$(python splunk_matrix_update.py)
echo $splunk_version

0 comments on commit 1d5064d

Please sign in to comment.