Skip to content

Commit

Permalink
Merge branch 'release/1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
LiruMouse committed Aug 26, 2022
2 parents 8071fdc + ae39c8c commit 936dd0d
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 30 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ notifications:
secure: dXrYK+6RSzaRqZols1gfKBb5uvP/uEdE1sQn2aCmpKX07r923Pnm1STmuj4Vx0tALY9FjN4enK5BqR2jCvW12ggxbbA4WAzMeKTCIwiv28+StlKKGs8DWtmmhd21w6P0uWP8Ayk7tSax1xYEyUAydFRG8UssCQpGUjbUI0+81BcvG55mXrvwFIx46/PlQxJzGQITCb6iAe5PeqO5Xi+XcjAf6wwP6juj77gw2GCOml05kPYzwO04hlqe60TRU4OXGTaqohRMeC9SsigUKM9eDQUqlzKYd0LQ2r2z9SqMiu3HC1xN5te5ugZ4roIPAV+hsx68LInCy3NsHYgAJabIciZs2egBM2ZtcQ8ERf2+Pg17TTnTv89twt5lJiNdBiP1BL9KjwuB7lpxmNiFju8NpenFrbbSyu8E7w/L8Ex9LrhQRlTVWheAEXtQ5aHwgkh731ipIDGoV2bjnqpmtYrnE1u4YW5WsB6IIy8gz2Qv/+enVVt0F89CEmeyFRT2ZEljKK6APx8qY0oFh1fhQ4Y17KX8sRbq7vqKaIhXZNFbctDF8dt6ycNbDHXhyCbHz/XOyayiyNo98FMXaNmCvQpUhIFx9ZS1fK8+Nj6opkZclDxJnsMHKesObDx4EXbhSMPUXZ214x5TppEBR9fggUfcLLL4BxX5aMFv//KR8y2HO4E=
install:
- mix do local.rebar --force, local.hex --force
- mix hex.organization auth simplifi --key ${HEX_API_KEY}
- mix deps.get
script:
- cd $TRAVIS_BUILD_DIR
Expand Down
2 changes: 1 addition & 1 deletion .travis/upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -e
# Only do so when a new version is tagged

if [[ ! -z "$TRAVIS_TAG" && "$TRAVIS_PULL_REQUEST" == "false" ]]; then
mix hex.publish --organization simplifi --yes
mix hex.publish --yes
else
echo "Skipping upload"
fi
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Copyright (c) 2022 Simpli.fi

MIT License

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 changes: 22 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
# ExSifiComix
# CoMix
Common mix.exs code that all projects can benefit from

## Features
- `CoMix.version/0`: Enables easy versioning in any git project through git tags
- One can run `git flow release start $VERSION; git flow release finish $VERSION` and be done

## Installation
Add this to the top of your mix.exs file:
```elixir
{:ok, _} = Application.ensure_all_started(:hex)
Mix.install([{:ex_sifi_comix, "~> 0.1.0", organization: "simplifi", runtime: false}])
unless Kernel.function_exported?(CoMix, :version, 0) do
{:ok, _} = Application.ensure_all_started(:hex)
Mix.install([{:ex_sifi_comix, "~> 1.0", runtime: false}])
end
```
Then set `version = ExSifiComix.version()` inside of the `def project`, instead of using a hardcoded version.
Then set `version = CoMix.version()` inside of the `def project`, instead of using a hardcoded version.

### Troubleshooting
#### Issue: Adding the `Mix.install` line to `mix.exs` causes `mix` commands like `mix deps.get` to error:
Expand All @@ -25,7 +31,7 @@ Then set `version = ExSifiComix.version()` inside of the `def project`, instead
```

##### Solution
Be sure to include the call to `Application.ensure_all_started(:hex)` before calling `Mix.Install/2`, to explicitly ensure hex is started.
Be sure to include the call to `Application.ensure_all_started(:hex)` before calling `Mix.install/2`, to explicitly ensure hex is started.

#### Issue: Commands like `mix local.hex --force` are failing (common for Travis):
```
Expand All @@ -41,23 +47,31 @@ This is because `mix.exs` needs to ensure hex is started, so the machine needs t
1. `cd` over to a directory without a `mix.exs`
- Short and to the point, `cd` will take you to the home dir, which is unlikely to have this file
2. Run whichever mix commands were failing
- Also run the commands necessary to authenticate with hex through mix, as they'll grant access to this and other private packages we need to `Mix.Install/2`
3. Run `cd -` to return to your previous directory, and proceed as usual

In `.travis.yml`, this usually looks something like
```yaml
install:
- cd
- mix do local.rebar --force, local.hex --force
- mix hex.organization auth simplifi --key ${HEX_API_KEY}
- cd -
```
#### Issue: The release build is failing to upload from Travis:
##### Solution
There may be a script trying to pull the version by reading mix.exs
A good solution to this that we've found is to look for and update these scripts:
- If they already have hex installed and authed, go ahead and use `mix app.version`
- If you don't have this command yet, it's easy to implement, see [here](https://mintcore.se/blog/2017/11/getting-elixir-app-version-from-command-line) ([Archived](https://web.archive.org/web/20200920053411/https://mintcore.se/blog/2017/11/getting-elixir-app-version-from-command-line))
- In other cases, it may be cleaner to have the script call the binary, after it has been built, with a `version` argument
Such solutions can look like `VERSION=$(_build/prod/rel/my_app/bin/my_app version | cut -d ' ' -f2)`

## Testing
Testing is done by running `mix test`.

## Releasing
You should be using [git flow](https://simplifi.atlassian.net/wiki/spaces/RTB/pages/28855038) here.
You should be using [git flow](https://github.com/petervanderdoes/gitflow-avh/wiki/Installation) here.

However, since this repo enables simplified versioning, we have chosen for the moment not to have it depend on itself.

As such, after running `git flow release start <X.Y.Z>`, you must create a commit bumping the version in mix.exs before running `git flow release finish <X.Y.Z>`.
2 changes: 1 addition & 1 deletion lib/ex_sifi_comix.ex → lib/comix.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule ExSifiComix do
defmodule CoMix do
@moduledoc File.read!(Path.expand("../README.md", __DIR__))

@default_version "v0.0.1-tagless"
Expand Down
14 changes: 7 additions & 7 deletions mix.exs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
defmodule ExSifiComix.MixProject do
defmodule CoMix.MixProject do
use Mix.Project

defp github, do: "https://github.com/simplifi/ex_sifi_comix"
defp github, do: "https://github.com/simplifi/comix"

def project do
[
app: :ex_sifi_comix,
version: "0.1.1",
app: :comix,
version: "1.0.0",
elixir: "~> 1.12",
package: package(),
description: "Common mix.exs code that all projects can benefit from",
Expand Down Expand Up @@ -36,9 +36,9 @@ defmodule ExSifiComix.MixProject do

defp package do
[
files: ["lib", "mix.exs", "README.md"],
maintainers: ["RTB"],
organization: "simplifi",
files: ["lib", "LICENSE", "mix.exs", "README.md"],
maintainers: ["Simpli.fi Development Team"],
licenses: ["MIT"],
links: %{Github: github()}
]
end
Expand Down
6 changes: 3 additions & 3 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
%{
"bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm", "7af5c7e09fe1d40f76c8e4f9dd2be7cebd83909f31fee7cd0e9eadc567da8353"},
"credo": {:hex, :credo, "1.6.5", "330ca591c12244ab95498d8f47994c493064b2689febf1236d43d596b4f2261d", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "101de53e6907397c3246ccd2cc9b9f0d3fc0b7805b8e1c1c3d818471fc85bafd"},
"dialyxir": {:hex, :dialyxir, "1.1.0", "c5aab0d6e71e5522e77beff7ba9e08f8e02bad90dfbeffae60eaf0cb47e29488", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "07ea8e49c45f15264ebe6d5b93799d4dd56a44036cf42d0ad9c960bc266c0b9a"},
"credo": {:hex, :credo, "1.6.6", "f51f8d45db1af3b2e2f7bee3e6d3c871737bda4a91bff00c5eec276517d1a19c", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "625520ce0984ee0f9f1f198165cd46fa73c1e59a17ebc520038b8fce056a5bdc"},
"dialyxir": {:hex, :dialyxir, "1.2.0", "58344b3e87c2e7095304c81a9ae65cb68b613e28340690dfe1a5597fd08dec37", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "61072136427a851674cab81762be4dbeae7679f85b1272b6d25c3a839aff8463"},
"earmark_parser": {:hex, :earmark_parser, "1.4.26", "f4291134583f373c7d8755566122908eb9662df4c4b63caa66a0eabe06569b0a", [:mix], [], "hexpm", "48d460899f8a0c52c5470676611c01f64f3337bad0b26ddab43648428d94aabc"},
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
"ex_doc": {:hex, :ex_doc, "0.28.4", "001a0ea6beac2f810f1abc3dbf4b123e9593eaa5f00dd13ded024eae7c523298", [:mix], [{:earmark_parser, "~> 1.4.19", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "bf85d003dd34911d89c8ddb8bda1a958af3471a274a4c2150a9c01c78ac3f8ed"},
"ex_doc": {:hex, :ex_doc, "0.28.5", "3e52a6d2130ce74d096859e477b97080c156d0926701c13870a4e1f752363279", [:mix], [{:earmark_parser, "~> 1.4.19", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "d2c4b07133113e9aa3e9ba27efb9088ba900e9e51caa383919676afdf09ab181"},
"file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"},
"git_cli": {:hex, :git_cli, "0.3.0", "a5422f9b95c99483385b976f5d43f7e8233283a47cda13533d7c16131cb14df5", [:mix], [], "hexpm", "78cb952f4c86a41f4d3511f1d3ecb28edb268e3a7df278de2faa1bd4672eaf9b"},
"jason": {:hex, :jason, "1.3.0", "fa6b82a934feb176263ad2df0dbd91bf633d4a46ebfdffea0c8ae82953714946", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "53fc1f51255390e0ec7e50f9cb41e751c260d065dcba2bf0d08dc51a4002c2ac"},
Expand Down
18 changes: 9 additions & 9 deletions test/ex_sifi_comix_test.exs → test/comix_test.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defmodule ExSifiComixTest do
defmodule CoMixTest do
use ExUnit.Case
doctest ExSifiComix
doctest CoMix

# Creates a temporary git repo for testing
defp create_temp_repo(path) do
Expand Down Expand Up @@ -32,8 +32,8 @@ defmodule ExSifiComixTest do
# Create temporary repo for testing
repo = create_temp_repo("tagless_repo")

# Get output of ExSifiComix.version inside repo
version = File.cd!(repo.path, fn -> ExSifiComix.version() end)
# Get output of CoMix.version inside repo
version = File.cd!(repo.path, fn -> CoMix.version() end)
# It should be marked tagless
assert String.ends_with?(version, "tagless")

Expand All @@ -47,13 +47,13 @@ defmodule ExSifiComixTest do
repo = create_temp_repo("properly_tagged_repo")
commit_and_tag(repo, "v4.34.1-test")

# Get output of ExSifiComix.version inside repo
version = File.cd!(repo.path, fn -> ExSifiComix.version() end)
# Get output of CoMix.version inside repo
version = File.cd!(repo.path, fn -> CoMix.version() end)

# It should not be marked tagless
assert !String.ends_with?(version, "tagless")

# Git describe should match version scheme and that should be the same as what ExSifiComix.version returns
# Git describe should match version scheme and that should be the same as what CoMix.version returns
expected = Git.describe!(repo, "--tags")
expected = match_version_scheme(expected)
assert [version] == expected
Expand All @@ -64,7 +64,7 @@ defmodule ExSifiComixTest do
repo = create_temp_repo("invalidly_tagged_repo")
# Tags without a leading v are invalid
commit_and_tag(repo, "4.34.1-test")
# ExSifiComix.version inside repo should throw
catch_error File.cd!(repo.path, fn -> ExSifiComix.version() end)
# CoMix.version inside repo should throw
catch_error(File.cd!(repo.path, fn -> CoMix.version() end))
end
end

0 comments on commit 936dd0d

Please sign in to comment.