diff --git a/.github/workflows/generate_default_project.yaml b/.github/workflows/generate_default_project.yaml new file mode 100644 index 0000000..570f13c --- /dev/null +++ b/.github/workflows/generate_default_project.yaml @@ -0,0 +1,24 @@ +name: Generate default project +on: + push: + +jobs: + test-Github-default-instance: + uses: ./.github/workflows/generate_default_project_reusable.yaml + with: + repo-path: github.com/karllu3/ds-lk-default.git + repo-user: karllu3 + repo-user-email: lukasz.karlowski@deepsense.ai + cookiecutter-profile: cookiecutter_default_gh.yaml + secrets: + REPO_TOKEN: ${{ secrets.REPO_KEY_GITHUB }} + + test-GitLab-default-instance: + uses: ./.github/workflows/generate_default_project_reusable.yaml + with: + repo-path: gitlab.com/lukasz.karlowski/ds-lk-default.git + repo-user: lukasz karlowski + repo-user-email: lukasz.karlowski@deepsense.ai + cookiecutter-profile: cookiecutter_default_gl.yaml + secrets: + REPO_TOKEN: ${{ secrets.REPO_KEY_GITLAB }} diff --git a/.github/workflows/generate_default_project_reusable.yaml b/.github/workflows/generate_default_project_reusable.yaml new file mode 100644 index 0000000..8eb8f60 --- /dev/null +++ b/.github/workflows/generate_default_project_reusable.yaml @@ -0,0 +1,87 @@ +name: Generate default project template + +on: + workflow_call: + inputs: + repo-path: + required: true + type: string + repo-user: + required: true + type: string + repo-user-email: + required: true + type: string + cookiecutter-profile: + required: true + type: string + secrets: + REPO_TOKEN: + required: true + +env: + REMOTE_REPO_REF: https://oauth2:${{ secrets.REPO_TOKEN }}@${{ inputs.repo-path }} + +jobs: + validate-instance: + runs-on: ubuntu-latest + container: python:3.11 + permissions: + contents: read + pages: write + + steps: + - uses: actions/checkout@v4 + + - name: Cache Dependencies + uses: actions/cache@v4 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Install Dependencies + run: pip install -r requirements.txt + + - name: Create Github project instance + run: cookiecutter . --no-input --config-file ${{ inputs.cookiecutter-profile }} + + - name: Prepare remote link + run: | + echo "remote repo ${{ env.REMOTE_REPO_REF }}" + + - name: Remote checkout + run: | + git clone ${{ env.REMOTE_REPO_REF }} ds-default-repo + cp -r ds-default/. ds-default-repo + + - name: Set safe directory + run: | + git config --global --add safe.directory /__w/ds-template/ds-template + + - name: Prepare local git repo + working-directory: ./ds-default-repo + run: | + git config --local user.email "${{ inputs.repo-user }}" + git config --local user.name "${{ inputs.repo-user-email }}" + git checkout -b ds-default-check + git add . + + - name: Validate package build + working-directory: ./ds-default-repo + run: | + python -m pip install . + + - name: Install pre-commit + run: pip3 install pre-commit + + - name: Run pre-commit checks + working-directory: ./ds-default-repo + run: pre-commit run --all-files --show-diff-on-failure --color always + + - name: Push repo + working-directory: ./ds-default-repo + run: | + git commit -m "Repo after creation" + git push --set-upstream origin ds-default-check -f \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 27bba79..34c4c91 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,7 +40,7 @@ jobs: pages: runs-on: ubuntu-latest - container: python:3.9-buster + container: python:3.11 steps: - uses: actions/checkout@v2 diff --git a/cookiecutter.json b/cookiecutter.json index 349add2..e9568e0 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -5,8 +5,8 @@ "__client_name_slug": "{{cookiecutter.client_name | slugify}}", "repo_name": "{{cookiecutter.__client_name_slug}}-{{cookiecutter.__project_name_slug}}", "ci": [ - "GitLab", "Github", + "GitLab", "None" ], "jupytext": [ @@ -18,4 +18,4 @@ "_copy_without_render": [ ".github/workflows/*.yml" ] - } \ No newline at end of file + } diff --git a/cookiecutter_default_gh.yaml b/cookiecutter_default_gh.yaml new file mode 100644 index 0000000..01463f8 --- /dev/null +++ b/cookiecutter_default_gh.yaml @@ -0,0 +1,5 @@ +default_context: + client_name: "ds" + project_name: "default" + ci: "Github" + jupytext": "No" diff --git a/cookiecutter_default_gl.yaml b/cookiecutter_default_gl.yaml new file mode 100644 index 0000000..ef9cf54 --- /dev/null +++ b/cookiecutter_default_gl.yaml @@ -0,0 +1,5 @@ +default_context: + client_name: "ds" + project_name: "default" + ci: "GitLab" + jupytext": "No" diff --git a/{{ cookiecutter.repo_name }}/.gitlab-ci.yml b/{{ cookiecutter.repo_name }}/.gitlab-ci.yml index d8ef467..417aaa1 100644 --- a/{{ cookiecutter.repo_name }}/.gitlab-ci.yml +++ b/{{ cookiecutter.repo_name }}/.gitlab-ci.yml @@ -1,9 +1,9 @@ default: tags: - - all-ds + - gitlab-org-docker variables: - PYTHON_DOCKER_IMAGE: python:3.9-buster + PYTHON_DOCKER_IMAGE: python:3.11 DOCKER_REGISTRY: $CI_REGISTRY/$CI_PROJECT_PATH PRECOMMIT_IMAGE: $DOCKER_REGISTRY/precommit diff --git a/{{ cookiecutter.repo_name }}/docker/precommit/Dockerfile b/{{ cookiecutter.repo_name }}/docker/precommit/Dockerfile index c451108..c3f474b 100644 --- a/{{ cookiecutter.repo_name }}/docker/precommit/Dockerfile +++ b/{{ cookiecutter.repo_name }}/docker/precommit/Dockerfile @@ -1,7 +1,7 @@ # Creates a dockerfile with pre-commit preconfigured. # Can be used to reduce time for linting stage. -FROM python:3.9-slim-buster +FROM python:3.11 ENV PRE_COMMIT_VERSION 3.0.4 diff --git a/{{ cookiecutter.repo_name }}/setup_dev_env.sh b/{{ cookiecutter.repo_name }}/setup_dev_env.sh index 8752f58..5290d7a 100755 --- a/{{ cookiecutter.repo_name }}/setup_dev_env.sh +++ b/{{ cookiecutter.repo_name }}/setup_dev_env.sh @@ -1,7 +1,7 @@ #!/bin/bash if [ ! -d venv ]; then - python3 -m venv venv + python3.11 -m venv venv . venv/bin/activate pip install --upgrade pip pip install --quiet wheel==0.41.3