Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
f964d1c
Replace autistici.org email addresses with eksperimental@tutamail.com
eksperimental Nov 20, 2026
2f575ef
Reset cached repo to upstream main branch when updating it
eksperimental Nov 20, 2026
f515e61
Accept http or https in Unicode latest-version redirect
eksperimental Nov 20, 2026
09d582a
Write Unicode version as major.minor in Elixir unicode-syntax page
eksperimental Nov 20, 2026
f87b018
Remove gradient dependency
eksperimental Nov 20, 2026
ece70a9
Upgrade to Erlang/OTP 29 and Elixir 1.20
eksperimental Nov 20, 2026
640a22a
Update dependencies to fix security advisories
eksperimental Nov 20, 2026
2eb210f
Remove the Phoenix web app
eksperimental Nov 20, 2026
ce5cb15
Replace Tentacat with Req for creating pull requests
eksperimental Nov 20, 2026
ad0a76f
Add tests for creating pull requests
eksperimental Nov 20, 2026
968ac8d
Fix compiler and logger warnings
eksperimental Nov 20, 2026
9498e35
Publish pull requests only when MAINTENANCE_PUBLISH is set
eksperimental Nov 20, 2026
9f37bf9
Remove the systemd unit file
eksperimental Nov 20, 2026
46b62c7
Update the fork's main branch when publishing
eksperimental Nov 20, 2026
969ee5a
Test that submit_pr does not publish when publishing is disabled
eksperimental Nov 20, 2026
53e0bed
Document where pull requests are opened
eksperimental Nov 20, 2026
76c822e
Update the contact email address in the README
eksperimental Nov 20, 2026
d174ede
Fix the OTP Unicode job's escript ordering and fail on its errors
eksperimental Nov 20, 2026
12b912b
Remove the release jobs, the sample job and their data dependency
eksperimental Nov 20, 2026
324f786
Remove the code that only made sense on an always-on server
eksperimental Nov 20, 2026
2ceb300
Ask GitHub whether a pull request exists and delete CubDB
eksperimental Nov 20, 2026
e70b1e9
Read the GitHub token only when it is used
eksperimental Nov 20, 2026
e8198cb
Split the job contract into status and prepare, and publish what run …
eksperimental Nov 20, 2026
f9fd2c0
Add the maintenance, maintenance.status, maintenance.run and maintena…
eksperimental Nov 20, 2026
2a33309
Rewrite the README usage around the three Mix commands
eksperimental Nov 20, 2026
52ae84b
Delete the Git and Util helpers that nothing calls
eksperimental Nov 21, 2026
d8ec1c9
Look up pull requests without sending the token
eksperimental Nov 21, 2026
28adfee
Return errors for a missing token and an unknown Unicode version
eksperimental Nov 21, 2026
31cc35c
Add the plan for running the maintenance jobs from Mix commands
eksperimental Nov 21, 2026
9bb23f5
Explain the forks in the help commands and the README
eksperimental Nov 21, 2026
ea42891
Publish to the configured account's fork unless --fork names another
eksperimental Nov 21, 2026
f2d5a03
Point the README's issue link at this repository
eksperimental Nov 21, 2026
fba210b
Say in the README that the app keeps Unicode up to date
eksperimental Nov 21, 2026
0ad9acf
Take the commit author and the GitHub account from whoever runs the app
eksperimental Nov 21, 2026
20fdcdf
Show how to set the commit identity in the env file
eksperimental Nov 21, 2026
31606f7
Describe the runner's own fork and identity in the CLI plan
eksperimental Nov 21, 2026
197eb94
Add an example env file
eksperimental Nov 21, 2026
f189343
Explain how to create the GitHub token and what it needs
eksperimental Nov 21, 2026
99efb27
Update the UTS #39 version in the Elixir Unicode syntax page
eksperimental Nov 21, 2026
f3e209c
Make mix check pass again
eksperimental Nov 21, 2026
24368ab
Run mix check in CI
eksperimental Nov 21, 2026
e92eadc
Run the CI cache action on Node 24
eksperimental Nov 21, 2026
21e7abf
Unzip the Unicode downloads again
eksperimental Nov 21, 2026
bb35a66
Let a closed pull request leave the job due
eksperimental Nov 21, 2026
8691a99
Leave an up-to-date job unpublished
eksperimental Nov 21, 2026
e13db19
Discard leftover changes when the checkout is already cached
eksperimental Nov 21, 2026
e7c45df
Update the OTP vendor info with the Unicode version
eksperimental Nov 21, 2026
8947223
Keep the tests off the network
eksperimental Nov 21, 2026
410ad4a
Print every status line when a job cannot be checked
eksperimental Nov 21, 2026
e48376a
Explain how to sync a fork whose main branch is ahead
eksperimental Nov 21, 2026
da9b0e7
Name the missing fork when run or publish stops
eksperimental Nov 21, 2026
bcce411
Say when GitHub's rate limit resets or the network fails
eksperimental Nov 21, 2026
f5251a5
Say which Unicode version could not be found
eksperimental Nov 21, 2026
49f872a
Run the tests in mix check
eksperimental Nov 21, 2026
06c5a28
Report network failures of the Unicode lookups
eksperimental Nov 21, 2026
7c225a0
Build the Unicode commit for the version status found
eksperimental Nov 21, 2026
9915462
Report failed downloads of the Unicode files
eksperimental Nov 21, 2026
ac1c499
Report Git failures when run sets up the checkout
eksperimental Nov 21, 2026
5196efb
Keep Git inside the cache when a checkout is missing
eksperimental Nov 22, 2026
99807fe
Report a Unicode zip that lacks a file the job copies
eksperimental Nov 22, 2026
f19f914
Report every Git failure of run's checkout setup
eksperimental Nov 22, 2026
5e87698
Report Git failures of the commit and the checkout config
eksperimental Nov 22, 2026
507ef71
Report the HTTP status of the current Unicode version lookup
eksperimental Nov 22, 2026
0b5db27
Read the main branch's commit from its own ls-remote line
eksperimental Nov 22, 2026
0e4953d
Report a Git failure around the commit instead of crashing
eksperimental Nov 22, 2026
a8f766a
Say why a commit failed when Git's first line does not
eksperimental Nov 22, 2026
2343876
Check out branches quietly so a hook's failure shows
eksperimental Nov 22, 2026
bd87a66
Say the commit is there when Git cannot describe it
eksperimental Nov 22, 2026
c7ed08b
Replace bytes that are not UTF-8 in what Git answered
eksperimental Nov 22, 2026
69273b2
Ask Git for the author in UTF-8
eksperimental Nov 22, 2026
e2f25f0
Check the oldest Elixir the app accepts
eksperimental Nov 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copy this file to .env, fill it in, and run `source .env`.

# Required. The fork that pull requests are opened in (--fork OWNER overrides it).
export GITHUB_ACCOUNT=your-account

# Required only for `mix maintenance.publish`. A token that can push to the fork
# and open pull requests in it. The README says how to create one.
export GITHUB_ACCESS_TOKEN=your-token

# Optional. Commit as someone other than your global Git identity.
# These apply to every Git command in the terminal where you ran `source .env`.
# export GIT_AUTHOR_NAME="Your Name"
# export GIT_AUTHOR_EMAIL="you@example.com"
# export GIT_COMMITTER_NAME="Your Name"
# export GIT_COMMITTER_EMAIL="you@example.com"
65 changes: 65 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Check

on:
push:
branches: [main]
pull_request:

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5

- uses: erlef/setup-beam@v1
with:
version-file: .tool-versions
version-type: strict

- uses: actions/cache@v6
with:
path: |
deps
_build
~/.mix/dialyxir_*
key: ${{ runner.os }}-mix-${{ hashFiles('.tool-versions', 'mix.lock') }}
restore-keys: ${{ runner.os }}-mix-

- run: mix deps.get

- run: mix check

# The check alias runs recode with autocorrect on, so a fixable issue
# gets rewritten and the step still passes. Fail if anything changed.
- run: git diff --exit-code

# Runs the same checks on the oldest Elixir that apps/maintenance/mix.exs
# accepts. mix test alone misses a call that only newer Elixir has when no
# test runs that line, or when it is in config/dev.exs.
check-oldest-elixir:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5

- uses: erlef/setup-beam@v1
with:
elixir-version: "1.15.7"
otp-version: "26.2.5.2"
version-type: strict

# The key must not start with the check job's restore key, or that job
# could restore a build made by this older Elixir.
- uses: actions/cache@v6
with:
path: |
deps
_build
~/.mix/dialyxir_*
key: ${{ runner.os }}-mix115-${{ hashFiles('mix.lock') }}
restore-keys: ${{ runner.os }}-mix115-

- run: mix deps.get

- run: mix check

- run: git diff --exit-code
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ erl_crash.dump
/tmp/

# Cached static files
/apps/maintenance_web/priv/static/

# Private Info
/.env
Expand Down
17 changes: 13 additions & 4 deletions .recode.exs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[
version: "0.7.3",
version: "0.9.0",
# Can also be set/reset with `--autocorrect`/`--no-autocorrect`.
autocorrect: true,
# With "--dry" no changes will be written to the files.
Expand All @@ -10,30 +10,39 @@
color: true,
# Can also be set/reset with `--verbose`/`--no-verbose`.
verbose: false,
# Can be overwritten with `--silent`/`--no-silent`.
# When enabled, suppresses all non-essential output during execution.
silent: false,
# Inputs can be a path, glob expression or list of paths and glob expressions.
# With the atom :formatter the inputs from .formatter.exs are
# used. also allowed in the list mentioned above.
# Can be overwritten by calling `mix recode "lib/**/*.ex"`.
inputs: ["{mix,.formatter}.exs", "{apps,config,lib,test}/**/*.{ex,exs}"],
formatters: [Recode.CLIFormatter],
# Can also be set/reset with `--manifest`/`--no-manifest`.
manifest: false,
tasks: [
# Tasks could be added by a tuple of the tasks module name and an options
# keyword list. A task can be deactivated by `active: false`. The execution of
# a deactivated task can be forced by calling `mix recode --task ModuleName`.
{Recode.Task.Format, active: false},
{Recode.Task.AliasExpansion, []},
{Recode.Task.AliasOrder, []},
{Recode.Task.Dbg, [autocorrect: false]},
{Recode.Task.EnforceLineLength, [active: false]},
{Recode.Task.FilterCount, []},
{Recode.Task.Format, [active: false]},
{Recode.Task.IOInspect, [autocorrect: false]},
{Recode.Task.LocalsWithoutParens, []},
# {Recode.Task.Moduledoc, []},
{Recode.Task.Moduledoc, [exclude: ["test/**/*.{ex,exs}", "mix.exs"], active: false]},
{Recode.Task.Nesting, []},
{Recode.Task.PipeChainStart, [active: false]},
{Recode.Task.PipeFunOne, []},
{Recode.Task.SinglePipe, []},
{Recode.Task.Specs,
[exclude: ["test/**/*.{ex,exs}", "mix.exs"], config: [only: :visible], active: false]},
{Recode.Task.TagFIXME, [exit_code: 2]},
{Recode.Task.TagTODO, [exit_code: 4, active: false]},
{Recode.Task.TestFileExt, []},
{Recode.Task.TestFile, []},
{Recode.Task.UnnecessaryIfUnless, []},
{Recode.Task.UnusedVariable, [active: false]}
]
Expand Down
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
elixir 1.18.2-otp-27
erlang 27.2.4
elixir 1.20.5-otp-29
erlang 29.1.2
171 changes: 155 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,174 @@
app which aims to automatize tasks in codebases of the Elixir, Erlang,
or any other project using a Git repository (only GitHub is initially supported).

It is mainly used to keep Unicode in Erlang/OTP and Elixir updated to the latest version.
See the pull requests submitted to
[Erlang/OTP](https://github.com/erlang/otp/pulls?q=is%3Apr+in%3Atitle+%22Update+Unicode%22) and
[Elixir](https://github.com/elixir-lang/elixir/pulls?q=is%3Apr+%28in%3Atitle+%22Update+Unicode%22+OR+in%3Atitle+%22Upgrade+Unicode%22%29).

## Feature Requests & Bug reports

Feel free to open up an issue <https://github.com/eksperimental/beam_meta/issues> with your request/report.
Feel free to open up an issue <https://github.com/eksperimental/maintenance/issues> with your request/report.

## Usage

1. Store `SECRET_KEY_BASE` and `GITHUB_ACCESS_TOKEN` in `.env`. You can use `.sample_env` as a base.
2. Make sure `.env` is loaded. If you run `source .env` in your terminal.
3. Run `iex -S mix phx.server`.
Maintenance is for occasional use: run it when a new version of Unicode comes out, which is about once a year. It is three Mix commands, run from the root of this repository.

```sh
mix maintenance # the commands, projects, jobs and the default fork
mix maintenance.status [PROJECT [JOB]] # which jobs are due
mix maintenance.run PROJECT JOB # build the commit locally
mix maintenance.publish PROJECT JOB # push it and open the pull request
```

### Before you start

Nothing about you is stored in this repository. The commits are authored with your own
Git identity, and `mix maintenance.run` stops if Git does not have one:

```sh
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
```

Copy `.example.env` to `.env`, which Git ignores, put your GitHub account and token in
it, and run `source .env` in your terminal:

```sh
export GITHUB_ACCOUNT=your-account
export GITHUB_ACCESS_TOKEN=your-token
```

`GITHUB_ACCOUNT` names the fork that pull requests are opened in, and each command
takes `--fork OWNER` to use another one.

#### Create the token

The token is used only by `mix maintenance.publish`, which pushes to the fork and
opens the pull request inside it. Nothing is written to the upstream projects, so the
token needs access to your forks only.

1. Fork [elixir-lang/elixir](https://github.com/elixir-lang/elixir) and
[erlang/otp](https://github.com/erlang/otp) into the account of `GITHUB_ACCOUNT`.
2. On GitHub, go to **Settings** > **Developer settings** > **Personal access tokens** >
**Fine-grained tokens**, and select **Generate new token**.
3. Set **Resource owner** to the account that holds the forks.
4. Under **Repository access**, select **Only select repositories**, and select the
`elixir` and `otp` forks.
5. Under **Repository permissions**, set:
- **Contents**: Read and write. Publishing pushes the branch and fast-forwards the
fork's main branch.
- **Pull requests**: Read and write. Publishing opens the pull request.
- **Workflows**: Read and write. The upstream commits that the fork's main branch is
fast-forwarded to often change files in `.github/workflows`, and GitHub rejects
those pushes without this permission.

GitHub adds **Metadata**: Read-only by itself.
6. Generate the token, and put it in `.env` as `GITHUB_ACCESS_TOKEN`.

A classic token works too, with the `repo` and `workflow` scopes, but it can reach every
repository of the account.

To commit with another identity than your global one, add it to `.env` too:

```sh
export GIT_AUTHOR_NAME="Your Name"
export GIT_AUTHOR_EMAIL="you@example.com"
export GIT_COMMITTER_NAME="Your Name"
export GIT_COMMITTER_EMAIL="you@example.com"
```

These variables apply to every Git command in the terminal where you ran `source .env`,
not only to this app.

### 1. See what is due

The following commands can be run within IEx.
```sh
mix maintenance.status
```

```elixir
# List projects
iex> Maintenance.projects()
[:otp]
```text
elixir unicode 17.0.0 -> 18.0.0 due
otp unicode 17.0.0 -> 18.0.0 due
```

# List jobs for a project
iex> Maintenance.jobs(:otp)
[:unicode]
A job is `due`, `up to date`, or due with a pull request that is already open
(`PR open: <url>`). A pull request that was closed without being merged does not block
the job: it shows as `due (closed PR: <url>)`, and `run` and `publish` go ahead. The
command reads from unicode.org and GitHub. It needs no token.

A job that cannot be checked shows the error on its line, and the command exits with an
error after it prints every line. For example, `error: <account>/otp not found on GitHub`
means that the account has no fork of `erlang/otp`. `run` and `publish` stop with the same
message. GitHub answers 60 requests an hour without a token, and the line says when
that limit resets once it is used up.

A `unicode` job says which Unicode version it could not find. `error: current Unicode
version not found in <url>` means that the project's source file at `<url>` has no version
where Maintenance looks for it, so the file has likely changed. `error: latest Unicode
version not found at https://www.unicode.org/versions/latest/` means that the page did not
redirect to the page of a Unicode version. When GitHub answers the request for the file with
an HTTP error, the line says `error: could not download <url> (HTTP <status>)`. When the
file or the page cannot be reached, it says `error: network error (<reason>)` instead.

### 2. Build the commit

```sh
mix maintenance.run otp unicode
```

# To run a specific job for a certain project
iex> Maintenance.Runner.update(:otp, :unicode)
{:ok, :no_update_needed}
This updates the checkout under `~/maintenance_data/cache` and commits the changes to
a new branch there. Nothing is pushed. The command prints the path of the checkout, the
files that changed, and the `git show` command to inspect the commit. It does nothing
if the job is up to date or a pull request for it is already open. You can run it again:
it starts from the upstream branch each time.

The Unicode files are downloaded from unicode.org once and then read from the cache. When a
download fails, `run` stops with `could not download <url> (HTTP <status>)` or
`network error (<reason>)`, and leaves the checkout as it was. When a downloaded zip lacks a
file the job copies, `run` stops with `<file> missing from <url>` before it touches the
checkout. When Git cannot clone or update the
checkout, for example because GitHub cannot be reached, `run` stops with the Git command
and the first line of what Git said, such as `git clone ... failed: fatal: unable to access ...`,
or its exit status when Git says nothing. When the checkout already has the files the job
writes, `run` stops with `nothing to commit, the checkout already has the files the job writes`.
When Git cannot list the files or name the author of the new commit, `run` stops with
`Committed <branch> in <path>, but could not describe it: git ... failed: exit status <N>`.
Git prints its reason above that line, and the commit stays on the branch.

### 3. Publish it

Publishing is the only step that needs a GitHub token. It is in `.env`, from
[Before you start](#before-you-start).

```sh
mix maintenance.publish otp unicode
```

Pull requests are opened inside a fork, never in the upstream project
(`elixir-lang/elixir` or `erlang/otp`), from the new branch into the fork's main branch.
The fork of `GITHUB_ACCOUNT` is used by default.

To use the fork of another account the token can push to, such as an organization, pass
`--fork OWNER` to `status`, `run` and `publish`. `status` and `run` look for an open
pull request on that same fork.

The title of the pull request is the subject of the commit.

The command pushes the commit that `mix maintenance.run` built, as it is. If there is
no such commit, it tells you to run `mix maintenance.run PROJECT JOB` first. If an
open pull request for the branch already exists on the fork, it prints its URL and
pushes nothing.

Each publish also fast-forwards the fork's main branch to the upstream commit
the job started from, so the pull request shows only the new commits. If the
fork's main branch has commits of its own, nothing is pushed and no pull
request is opened. To discard those commits, open the fork on GitHub, click
**Sync fork**, then **Discard commits**. Then run `mix maintenance.publish` again.

## Contact

Eksperimental <eksperimental (at) autistici (dot) org>
Eksperimental <eksperimental (at) tutamail (dot) com>

## License

Expand Down
Loading