-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #177 from nimblehq/release/4.0.0
Release - 4.0.0
- Loading branch information
Showing
202 changed files
with
6,473 additions
and
1,648 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
Prefer to use the image from the Hexpm team instead of the Docker team, the reason below | ||
was mentioned on the [Elixir Forums](https://elixirforum.com/t/yet-another-elixir-and-erlang-docker-image/28740): | ||
|
||
- Image tags are not immutable. | ||
- Delay in the availability of new versions. | ||
- Cannot pick the combination of Elixir and Erlang versions you want. | ||
|
||
Refer: | ||
|
||
- [hexpm/elixir](https://hub.docker.com/r/hexpm/elixir) | ||
- [hexpm/erlang](https://hub.docker.com/r/hexpm/erlang) | ||
|
||
Example Dockerfile: | ||
|
||
```dockerfile | ||
FROM hexpm/elixir:1.11.0-erlang-23.1.1-alpine-3.12.0 AS build | ||
|
||
.... | ||
FROM alpine:3.12.0 AS app | ||
... | ||
|
||
COPY --from=build --chown=nobody:nobody /app/_build/prod/rel/app ./ | ||
... | ||
``` | ||
|
||
Based on the image tag, it's clear which versions we use in the Build Release step | ||
|
||
- Elixir: 1.11.0 | ||
- Erlang: 23.1.1 | ||
- Alpine: 3.12.0 | ||
|
||
Easily we can choose the OS to run the app on, that is `alpine:3.12.0` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Phoenix/Mix template for projects at Nimble. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
NimbleTemplate uses Github Actions as the CI, the workflow files are located under the [.github/workflows/](https://github.com/nimblehq/elixir-templates/tree/develop/.github/workflows) directory. | ||
|
||
There are 2 types of tests, **Template tests** and **Variant tests** | ||
|
||
## 1/ Template test | ||
|
||
All test files are located under `test/` directory. | ||
|
||
```text | ||
. | ||
├── ... | ||
├── test | ||
│ ├── ... | ||
│ ├── nimble_template | ||
│ │ └── addons | ||
│ │ │ ├── ... | ||
│ │ │ ├── common_mix_phoenix_addon_test.exs | ||
│ │ │ └── variants | ||
│ │ │ │ └── mix | ||
│ │ │ │ │ ├── ... | ||
│ │ │ │ │ └── mix_addon_test.exs | ||
│ │ │ │ └── phoenix | ||
│ │ │ │ │ └── common_phoenix_addon_test.exs | ||
│ │ │ │ │ └── api | ||
│ │ │ │ │ │ ├── ... | ||
│ │ │ │ │ │ └── api_addon_test.exs | ||
│ │ │ │ │ └── live | ||
│ │ │ │ │ │ ├── ... | ||
│ │ │ │ │ │ └── live_addon_test.exs | ||
│ │ │ │ │ └── web | ||
│ │ │ │ │ │ ├── ... | ||
│ │ │ │ │ │ └── web_addon_test.exs | ||
``` | ||
|
||
## 2/ Variant test | ||
|
||
NimbleTemplate supports 4 variants: | ||
|
||
- Mix | ||
- Web | ||
- API | ||
- Live | ||
|
||
### 2.1/ Mix project | ||
|
||
A Mix project could be either a Standard project or a Custom project. | ||
|
||
- `mix new awesome_project` | ||
- `mix new awesome_project --module=CustomModuleName` | ||
- `mix new awesome_project --app=custom_otp_app_name` | ||
- `mix new awesome_project --module=CustomModuleName --app=custom_otp_app_name` | ||
|
||
Each project could include a `supervision tree`. | ||
|
||
- `mix new awesome_project` | ||
- `mix new awesome_project --sup` | ||
- `mix new awesome_project --module=CustomModuleName --app=custom_otp_app_name` | ||
- `mix new awesome_project --module=CustomModuleName --app=custom_otp_app_name --sup` | ||
|
||
Adding it all together, totals to 4 variant test cases. | ||
|
||
- Applying the `Mix variant` to a `Standard Mix project` | ||
- Applying the `Mix variant` to a `Custom Mix project` | ||
- Applying the `Mix variant` to a `Standard Mix project with the --sup option` | ||
- Applying the `Mix variant` to a `Custom Mix project with the --sup option` | ||
|
||
### 2.2/ Phoenix project | ||
|
||
A Phoenix project could be either a Web, LiveView, or API. | ||
|
||
- Web variants support HTML and Assets. | ||
|
||
```bash | ||
mix phx.new awesome_project --no-live | ||
``` | ||
|
||
- LiveView projects include HTML and Assets configuration. | ||
|
||
```bash | ||
mix phx.new awesome_project | ||
``` | ||
|
||
- API variants do NOT support HTML and Assets configuration. | ||
|
||
```bash | ||
mix phx.new awesome_project --no-html --no-assets | ||
``` | ||
|
||
- Custom project variants allow us to modify the app name or module name. | ||
|
||
```bash | ||
# Use CustomModuleName | ||
mix phx.new awesome_project --module=CustomModuleName | ||
|
||
# Use custom OTP app name | ||
mix phx.new awesome_project --app=custom_otp_app_name | ||
|
||
# Use custom module and app name | ||
mix phx.new awesome_project --module=CustomModuleName --app=custom_otp_app_name | ||
``` | ||
|
||
So it ends up with 6 project types: | ||
|
||
Web project | ||
|
||
- Standard (`mix phx.new awesome_project --no-live`) | ||
- Custom (`mix phx.new awesome_project --no-live --module=CustomModuleName --app=custom_otp_app_name`) | ||
|
||
API project | ||
|
||
- Standard (`mix phx.new awesome_project --no-html --no-assets`) | ||
- Custom (`mix phx.new awesome_project --no-html --no-assets --module=CustomModuleName --app=custom_otp_app_name`) | ||
|
||
LiveView project | ||
|
||
- Standard (`mix phx.new awesome_project`) | ||
- Custom (`mix phx.new awesome_project --module=CustomModuleName --app=custom_otp_app_name`) | ||
|
||
Putting it all together, there are 8 variants of test cases. | ||
|
||
- Applying the `API variant` to a `Standard Web project` | ||
- Applying the `API variant` to a `Custom Web project` | ||
- Applying the `API variant` to a `Standard API project` | ||
- Applying the `API variant` to a `Custom API project` | ||
- Applying the `Web variant` to a `Standard Web project` | ||
- Applying the `Web variant` to a `Custom Web project` | ||
- Applying the `Live variant` to a `Standard LiveView project` | ||
- Applying the `Live variant` to a `Custom LiveView project` | ||
|
||
## Note | ||
|
||
Make sure the Phoenix version is the same between local development and CI, otherwise there will be some error in the unit test. | ||
|
||
- Phoenix version on CI can be found in: `.github/workflows/test_template.yml` | ||
- Install a correct Phoenix version on local via command: `mix archive.install hex phx_new __PHOENIX_VERSION__` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
**Developed by [Nimble](https://nimblehq.co/)** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
## Table of Contents | ||
|
||
- [[Home]] | ||
|
||
## Architecture | ||
|
||
- [[Docker]] | ||
- [[Testing]] |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Apply API variant | ||
|
||
on: push | ||
|
||
jobs: | ||
standard_api_project: | ||
name: Test on a Standard API project | ||
uses: ./.github/workflows/reusable_phoenix_project.yml | ||
with: | ||
new_project_options: "--no-html --no-assets" | ||
variant: "api" | ||
|
||
non-standard_api_project: | ||
name: Test on a Non-Standard API project | ||
uses: ./.github/workflows/reusable_phoenix_project.yml | ||
with: | ||
new_project_options: "--no-html --no-assets --module=SampleCustomModule --app=sample_custom_app" | ||
variant: "api" | ||
|
||
standard_web_project: | ||
name: Test on a Standard Web project | ||
uses: ./.github/workflows/reusable_phoenix_project.yml | ||
with: | ||
new_project_options: "" | ||
variant: "api" | ||
|
||
non-standard_web_project: | ||
name: Test on a Non-Standard Web project | ||
uses: ./.github/workflows/reusable_phoenix_project.yml | ||
with: | ||
new_project_options: "--module=SampleCustomModule --app=sample_custom_app" | ||
variant: "api" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Apply Live variant | ||
|
||
on: push | ||
|
||
jobs: | ||
standard_project: | ||
name: Test on a Standard Live project | ||
uses: ./.github/workflows/reusable_phoenix_project.yml | ||
with: | ||
new_project_options: "" | ||
variant: "live" | ||
|
||
non-standard_project: | ||
name: Test on a Non-Standard Live project | ||
uses: ./.github/workflows/reusable_phoenix_project.yml | ||
with: | ||
new_project_options: "--module=SampleCustomModule --app=sample_custom_app" | ||
variant: "live" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Apply Mix variant | ||
|
||
on: push | ||
|
||
jobs: | ||
standard_mix_project: | ||
name: Test on a Standard Mix project | ||
uses: ./.github/workflows/reusable_mix_project.yml | ||
with: | ||
new_project_options: "" | ||
|
||
non-standard_mix_project: | ||
name: Test on a Non-Standard Mix project | ||
uses: ./.github/workflows/reusable_mix_project.yml | ||
with: | ||
new_project_options: "--module=SampleCustomModule --app=sample_custom_app" | ||
|
||
standard_mix_supervision_project: | ||
name: Test on a Standard Supervision Mix project | ||
uses: ./.github/workflows/reusable_mix_project.yml | ||
with: | ||
new_project_options: "--sup" | ||
|
||
non-standard_mix_supervision_project: | ||
name: Test on a Non-Standard Supervision Mix project | ||
uses: ./.github/workflows/reusable_mix_project.yml | ||
with: | ||
new_project_options: "--sup --module=SampleCustomModule --app=sample_custom_app" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Apply Web variant | ||
|
||
on: push | ||
|
||
jobs: | ||
standard_project: | ||
name: Test on a Standard Web project | ||
uses: ./.github/workflows/reusable_phoenix_project.yml | ||
with: | ||
new_project_options: "--no-live" | ||
variant: "web" | ||
|
||
non-standard_project: | ||
name: Test on a Non-Standard Web project | ||
uses: ./.github/workflows/reusable_phoenix_project.yml | ||
with: | ||
new_project_options: "--no-live --module=SampleCustomModule --app=sample_custom_app" | ||
variant: "web" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: "Publish to Hex.pm" | ||
name: Publish to Hex package manager | ||
|
||
on: | ||
workflow_run: | ||
|
@@ -11,24 +11,30 @@ on: | |
workflow_dispatch: | ||
|
||
env: | ||
OTP_VERSION: 23.3 | ||
ELIXIR_VERSION: 1.11.4 | ||
OTP_VERSION: 24.2.2 | ||
ELIXIR_VERSION: 1.13.3 | ||
|
||
jobs: | ||
jobs: | ||
publish: | ||
name: Publish hex package | ||
|
||
runs-on: ubuntu-latest | ||
|
||
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }} | ||
|
||
steps: | ||
- name: Cancel Previous Runs | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{ github.token }} | ||
|
||
- uses: actions/checkout@v2 | ||
|
||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ github.event.workflow_run.head_branch || github.ref }} | ||
|
||
- uses: erlef/setup-elixir@v1 | ||
- name: Set up Elixir ${{ env.ELIXIR_VERSION }} and OTP ${{ env.OTP_VERSION }} | ||
uses: erlef/setup-elixir@v1 | ||
with: | ||
otp-version: ${{ env.OTP_VERSION }} | ||
elixir-version: ${{ env.ELIXIR_VERSION }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Publish Wiki | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
paths: | ||
- .github/wiki/** | ||
|
||
jobs: | ||
publish: | ||
name: Publish wiki | ||
uses: nimblehq/github-actions-workflows/.github/workflows/[email protected] | ||
with: | ||
USER_NAME: github-wiki-action | ||
USER_EMAIL: [email protected] | ||
secrets: | ||
USER_TOKEN: ${{ secrets.WIKI_ACTION_TOKEN }} |
Oops, something went wrong.