Skip to content

Unnecessary .github folder and missing dependabot implementation when using gitlab as repository host #454

Open

Description

@mbwinkler

Currently, creating a project from the template with a repository target hosted on gitlab results in an unnecessary .github folder and no dependabot implementation in .gitlab-ci.yml.

This could be fixed with the following logic:

  1. Always create all necessary CI/CD files for both gitlab & github on generation
  2. Remove unnecessary files/folders using a post-generation hook

This hook would be stored in hooks/post_gen_project.py and would look something like this

import os
import shutil

# Determine the target platform
target_platform = '{{ cookiecutter.__ci }}'

# Define paths to CI directories
github_ci_path = os.path.join(os.getcwd(), '.github')
gitlab_ci_file = os.path.join(os.getcwd(), '.gitlab-ci.yml')
gitlab_dependabot_file = os.path.join(os.getcwd(), 'dependabot.yml')

if target_platform == 'github':
    # Remove the GitLab CI file if the target is GitHub
    if os.path.exists(gitlab_ci_file):
        os.remove(gitlab_ci_file)
        os.remove(gitlab_dependabot_file)
elif target_platform == 'gitlab':
    # Remove the GitHub Actions directory if the target is GitLab
    if os.path.exists(github_ci_path):
        shutil.rmtree(github_ci_path)

Activity

  1. henryiii commented on Jul 17, 2024

    @henryiii
    Collaborator

    And for copier? I believe I didn't do this because I was avoiding any custom hooks (we used to have several for things now handled via the template engine). But maybe it would be a good idea to use them for this.

    What is dependabot supposed to look like for gitlab?

  2. mbwinkler commented on Jul 19, 2024

    @mbwinkler
    Author

    I am not sure about copier.

    Dependabot-gitlab is implemented pretty much the same way Dependabot is on Github.

    Add the .gitlab/dependabot.yml with the following basic contents:

    version: 2
    updates:
      - package-ecosystem: package-manager
        directory: /
        schedule:
          interval: daily

    More information on the setup here.

  3. henryiii commented on Aug 20, 2024

    @henryiii
    Collaborator

    Can .gitlab-ci.yml go in .gitlab?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions