Git Product home page Git Product logo

copiertemplate.jl's Introduction

COPIERTemplate.jl - Copier OPInionated Evolving Reusable Template

Stable Documentation In development documentation

Lint workflow Status Build Status Test workflow status Lint workflow Status Docs workflow Status Coverage DOI

This is

  • a copier template/skeleton for Julia packages (see folder template); and
  • a package created with the template that wraps copier in Julia using PythonCall.

The template

  • is opinionated but allows options;
  • can be applied to existing packages (thanks to copier);
  • is automatically reapplied through Pull Requests made by the Copier.yml workflow.

asciicast

Additional wishlist

  • Use as template for other templates (Maybe just use forks?)

But why?

Because I have around 50 packages that follow similar configuration (but not equal), and I don't want to go through all of them manually every time I have a small change.

What about mass updates using the GitHub API?

I have done that in the past, but now I want even less manual intervention. This will still require manual installation for the first time, and will still allow verifying the pull requests.

How to install

Warning

It is unknown if the package works on Windows due to an issue with unsupported paths. See Issue #21. If it doesn't work, let us know, and use the alternative installation.

  1. Install this package, use the module and run COPIERTemplate.generate(path).

    Alternatively, this can also be installed directly via copier, with the command

    copier copy https://github.com/abelsiqueira/COPIERTemplate.jl YourPackage.jl

    Follow the instructions. In particular you will need a UUID. Your Linux might have uuidgen installed, but you can also use Julia:

    using UUIDs
    uuid4()
  2. The resulting folder will not be a git package yet (to avoid trust issues), so you need to handle that yourself. First, install pre-commit, and then issue:

    cd YourPackage.jl
    git init
    git add .
    pre-commit run -a # Fix possible pre-commit issues
    git add .
    git commit -m "First commit"
    pre-commit install # Future commits can't be directly to main unless you use -n

    It is common to have some pre-commit issues due to your package's name length triggering JuliaFormatter.

  3. Create a repo on GitHub and push it

    git remote add origin https://github.com/UserName/PackageName.jl
  4. Create a DOCUMENTER_KEY, which will be used by for documentation purposes.

    pkg> activate --temp
    pkg> add DocumenterTools
    julia> using DocumenterTools
    julia> DocumenterTools.genkeys(user="UserName", repo="PackageName.jl")

    Follow the instruction in the terminal.

  5. Create a Personal Access Token to be used by the Copier workflow.

    1. Go to https://github.com/settings/tokens.
    2. Create a token with "Content", "Pull-request", and "Workflows" permissions.
    3. Copy the Token.
    4. Go to your YOUR_PACKAGE_URL/settings/secrets/actions.
    5. Create a "New repository secret" named COPIER_PAT.
  6. Before releasing, enable Zenodo integration at https://zenodo.org/account/settings/github/.

What are all these files?

Since there are so many files, an explanation is in order.

Basic package structure

This structure should be self-informative, as it is part of what most people use, with a few exceptions mentioned below.

  • PackageName.jl/
    • docs/
      • src/
        • contributing.md
        • developer.md
        • index.md
        • reference.md
      • make.jl
      • Project.toml
    • src/
      • PackageName.jl
    • test/
      • Project.toml
      • runtests.jl
    • LICENSE.md
    • Project.toml
    • README.md

The exceptions are:

  • test/Project.toml: This is supported for a while, and it looks better. Time will tell if it was a bad idea.
  • docs/src/contributing.md: Also known as CONTRIBUTING.md, it explains how contributors can get involved in the project.
  • docs/src/developer.md: Also known as README.dev.md, it explains how to setup your local environment.

Linting and Formatting

The most important file related to linting and formatting is .pre-commit-config.yaml, which is the configuration for pre-commit. It defines a list of linters and formatters for Julia, Markdown, YAML, and JSON.

It requires installing pre-commit (I recommend installing it globally with pipx). Installing pre-commit (pre-commit install) will make sure that it runs right the relevant hooks before commiting. Additionally, if you run pre-commit run -a, it runs all hooks, which can be used for Linting.

Some hooks in the .pre-commit-config.yaml file have configuration files of their own: .JuliaFormatter.toml, .markdownlint.json, .markdown-link-config.json, and .yamllint.yml.

Also slightly related, is the .editorconfig file, which tells your editor, if you install the coorect plugin, how to format some things.

GitHub Workflows

The select a few workflows, with a strong possibility of expanding in the future:

  • CompatHelper.yml: Should be well known by now. It checks that your Project.toml compat entries are up-to-date.
  • Copier.yml: This will periodically check the template for updates. If there are updates, this action creates a pull request updating your repo.
  • Docs.yml: Build the docs. Only runs when relevant files change.
  • Lint.yml: Run the linter and formatter through the command pre-commit run -a.
  • TagBot.yml: Create GitHub releases automatically after your new release is merged on the Registry.
  • Test.yml: Run the tests.

Users and Examples

The following are users and examples of repos using this template, or other templates based on it. Feel free to create a pull request to add your repo.

copiertemplate.jl's People

Contributors

abelsiqueira avatar tmigot avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.