Skip to content

Commit c2de758

Browse files
committed
ci: add elixir workflows
1 parent 1e3bfd0 commit c2de758

23 files changed

+330
-63
lines changed

.github/actions/action.yml

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Setup Elixir Project
2+
description: Checks out the code, configures Elixir, fetches dependencies, and manages build caching.
3+
inputs:
4+
otp-version:
5+
required: true
6+
type: string
7+
description: OTP version to set up
8+
elixir-version:
9+
required: true
10+
type: string
11+
description: Elixir version to set up
12+
build-deps:
13+
required: false
14+
type: boolean
15+
default: true
16+
description: True if we should compile dependencies
17+
build-app:
18+
required: false
19+
type: boolean
20+
default: true
21+
description: True if we should compile the application itself
22+
build-flags:
23+
required: false
24+
type: string
25+
default: '--all-warnings'
26+
description: Flags to pass to mix compile
27+
install-rebar:
28+
required: false
29+
type: boolean
30+
default: true
31+
description: By default, we will install Rebar (mix local.rebar --force).
32+
install-hex:
33+
required: false
34+
type: boolean
35+
default: true
36+
description: By default, we will install Hex (mix local.hex --force).
37+
cache-key:
38+
required: false
39+
type: string
40+
default: 'v1'
41+
description: If you need to reset the cache for some reason, you can change this key.
42+
runs:
43+
using: "composite"
44+
steps:
45+
- name: Setup Elixir
46+
uses: erlef/setup-beam@v1
47+
with:
48+
otp-version: ${{ inputs.otp-version }}
49+
elixir-version: ${{ inputs.elixir-version }}
50+
51+
- name: Get deps cache
52+
uses: actions/cache@v3
53+
id: deps-cache
54+
with:
55+
path: deps/
56+
key: ${{ runner.os }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '**/mix.lock')) }}
57+
restore-keys: |
58+
${{ runner.os }}-mix-
59+
60+
- name: Get build cache
61+
uses: actions/cache@v3
62+
id: build-cache
63+
with:
64+
path: _build/${{env.MIX_ENV}}/
65+
key: build-${{ inputs.cache-key }}-${{ runner.os }}-${{ inputs.otp-version }}-${{ inputs.elixir-version }}-${{ env.MIX_ENV }}-${{ hashFiles('**/mix.lock') }}
66+
restore-keys: |
67+
build-${{ inputs.cache-key }}-${{ runner.os }}-${{ inputs.otp-version }}-${{ inputs.elixir-version }}-${{ env.MIX_ENV }}-
68+
69+
- name: Clean to rule out incremental build as a source of flakiness
70+
if: github.run_attempt != '1'
71+
run: |
72+
mix deps.clean --all
73+
mix clean
74+
shell: sh
75+
76+
- name: Install Rebar
77+
run: mix local.rebar --force
78+
shell: sh
79+
if: inputs.install-rebar == 'true'
80+
81+
- name: Install Hex
82+
run: mix local.hex --force
83+
shell: sh
84+
if: inputs.install-hex == 'true'
85+
86+
- name: Install Dependencies
87+
run: mix deps.get
88+
shell: sh
89+
90+
- name: Compile Dependencies
91+
run: mix deps.compile
92+
shell: sh
93+
if: inputs.build-deps == 'true'
94+
95+
- name: Compile Application
96+
run: mix compile ${{ inputs.build-flags }}
97+
shell: sh
98+
if: inputs.build-app == 'true'

.github/workflows/style.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Code Quality
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
types: [opened, synchronize]
7+
8+
jobs:
9+
style:
10+
runs-on: ubuntu-latest
11+
name: Code Quality
12+
13+
strategy:
14+
matrix:
15+
otp: [26.x]
16+
elixir: [1.14.x]
17+
18+
steps:
19+
- name: ☁️ Checkout repository
20+
uses: actions/checkout@v3
21+
22+
- name: 💧 Setup Elixir ${{ matrix.elixir }} (OTP ${{matrix.otp}})
23+
uses: ./.github/actions
24+
with:
25+
otp-version: ${{ matrix.otp }}
26+
elixir-version: ${{ matrix.elixir }}
27+
build-flags: --all-warnings --warnings-as-errors
28+
29+
- name: 🎨 Check code formating
30+
run: mix format --check-formatted
31+
32+
- name: 🔍 Lint the code
33+
run: mix credo --all --strict

.github/workflows/test.yml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Build and Test
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
types: [opened, synchronize]
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
name: OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}}
14+
env:
15+
MIX_ENV: test
16+
17+
strategy:
18+
matrix:
19+
otp: [26.x]
20+
elixir: [1.14.x]
21+
22+
services:
23+
db:
24+
image: postgres:14.1
25+
ports:
26+
- 5432:5432
27+
env:
28+
POSTGRES_USERNAME: postgres
29+
POSTGRES_PASSWORD: postgres
30+
POSTGRES_HOSTNAME: 0.0.0.0
31+
32+
steps:
33+
- name: ☁️ Checkout repository
34+
uses: actions/checkout@v3
35+
36+
- name: 💧 Setup Elixir ${{ matrix.elixir }} (OTP ${{matrix.otp}})
37+
uses: ./.github/actions
38+
with:
39+
otp-version: ${{ matrix.otp }}
40+
elixir-version: ${{ matrix.elixir }}
41+
build-flags: --all-warnings --warnings-as-errors
42+
43+
- name: 🔬 Run the tests
44+
run: mix test --warnings-as-errors

CODE_OF_CONDUCT.md

+107-50
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,132 @@
1-
# Contributor Covenant Code of Conduct
1+
Contributor Covenant Code of Conduct
22

33
## Our Pledge
44

5-
In the interest of fostering an open and welcoming environment, we as
6-
contributors and maintainers pledge to making participation in our project and
7-
our community a harassment-free experience for everyone, regardless of age,
8-
body size, disability, ethnicity, gender identity and expression, level of
9-
experience, nationality, personal appearance, race, religion, or sexual
5+
We as members, contributors, and leaders pledge to make participation in our
6+
community a harassment-free experience for everyone, regardless of age, body
7+
size, visible or invisible disability, ethnicity, sex characteristics, gender
8+
identity and expression, level of experience, education, socio-economic status,
9+
nationality, personal appearance, race, caste, color, religion, or sexual
1010
identity and orientation.
1111

12-
## Our Standards
13-
14-
Examples of behavior that contributes to creating a positive environment
15-
include:
16-
17-
- Using welcoming and inclusive language
18-
- Being respectful of differing viewpoints and experiences
19-
- Gracefully accepting constructive criticism
20-
- Focusing on what is best for the community
21-
- Showing empathy towards other community members
12+
We pledge to act and interact in ways that contribute to an open, welcoming,
13+
diverse, inclusive, and healthy community.
2214

23-
Examples of unacceptable behavior by participants include:
15+
## Our Standards
2416

25-
- The use of sexualized language or imagery and unwelcome sexual attention or
26-
advances
27-
- Trolling, insulting/derogatory comments, and personal or political attacks
28-
- Public or private harassment
29-
- Publishing others' private information, such as a physical or electronic
30-
address, without explicit permission
31-
- Other conduct which could reasonably be considered inappropriate in a
17+
Examples of behavior that contributes to a positive environment for our
18+
community include:
19+
20+
* Demonstrating empathy and kindness toward other people
21+
* Being respectful of differing opinions, viewpoints, and experiences
22+
* Giving and gracefully accepting constructive feedback
23+
* Accepting responsibility and apologizing to those affected by our mistakes,
24+
and learning from the experience
25+
* Focusing on what is best not just for us as individuals, but for the overall
26+
community
27+
28+
Examples of unacceptable behavior include:
29+
30+
* The use of sexualized language or imagery, and sexual attention or advances of
31+
any kind
32+
* Trolling, insulting or derogatory comments, and personal or political attacks
33+
* Public or private harassment
34+
* Publishing others' private information, such as a physical or email address,
35+
without their explicit permission
36+
* Other conduct which could reasonably be considered inappropriate in a
3237
professional setting
3338

34-
## Our Responsibilities
39+
## Enforcement Responsibilities
3540

36-
Project maintainers are responsible for clarifying the standards of acceptable
37-
behavior and are expected to take appropriate and fair corrective action in
38-
response to any instances of unacceptable behavior.
41+
Community leaders are responsible for clarifying and enforcing our standards of
42+
acceptable behavior and will take appropriate and fair corrective action in
43+
response to any behavior that they deem inappropriate, threatening, offensive,
44+
or harmful.
3945

40-
Project maintainers have the right and responsibility to remove, edit, or
41-
reject comments, commits, code, wiki edits, issues, and other contributions
42-
that are not aligned to this Code of Conduct, or to ban temporarily or
43-
permanently any contributor for other behaviors that they deem inappropriate,
44-
threatening, offensive, or harmful.
46+
Community leaders have the right and responsibility to remove, edit, or reject
47+
comments, commits, code, wiki edits, issues, and other contributions that are
48+
not aligned to this Code of Conduct, and will communicate reasons for moderation
49+
decisions when appropriate.
4550

4651
## Scope
4752

48-
This Code of Conduct applies both within project spaces and in public spaces
49-
when an individual is representing the project or its community. Examples of
50-
representing a project or community include using an official project e-mail
51-
address, posting via an official social media account, or acting as an
52-
appointed representative at an online or offline event. Representation of a
53-
project may be further defined and clarified by project maintainers.
53+
This Code of Conduct applies within all community spaces, and also applies when
54+
an individual is officially representing the community in public spaces.
55+
Examples of representing our community include using an official e-mail address,
56+
posting via an official social media account, or acting as an appointed
57+
representative at an online or offline event.
5458

5559
## Enforcement
5660

5761
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58-
reported by contacting the project team at <[email protected]>. All
59-
complaints will be reviewed and investigated and will result in a response that
60-
is deemed necessary and appropriate to the circumstances. The project team is
61-
obligated to maintain confidentiality with regard to the reporter of an
62-
incident. Further details of specific enforcement policies may be posted
63-
separately.
62+
reported to the community leaders responsible for enforcement at
63+
64+
All complaints will be reviewed and investigated promptly and fairly.
65+
66+
All community leaders are obligated to respect the privacy and security of the
67+
reporter of any incident.
68+
69+
## Enforcement Guidelines
70+
71+
Community leaders will follow these Community Impact Guidelines in determining
72+
the consequences for any action they deem in violation of this Code of Conduct:
73+
74+
### 1. Correction
75+
76+
**Community Impact**: Use of inappropriate language or other behavior deemed
77+
unprofessional or unwelcome in the community.
78+
79+
**Consequence**: A private, written warning from community leaders, providing
80+
clarity around the nature of the violation and an explanation of why the
81+
behavior was inappropriate. A public apology may be requested.
6482

65-
Project maintainers who do not follow or enforce the Code of Conduct in good
66-
faith may face temporary or permanent repercussions as determined by other
67-
members of the project's leadership.
83+
### 2. Warning
84+
85+
**Community Impact**: A violation through a single incident or series of
86+
actions.
87+
88+
**Consequence**: A warning with consequences for continued behavior. No
89+
interaction with the people involved, including unsolicited interaction with
90+
those enforcing the Code of Conduct, for a specified period of time. This
91+
includes avoiding interactions in community spaces as well as external channels
92+
like social media. Violating these terms may lead to a temporary or permanent
93+
ban.
94+
95+
### 3. Temporary Ban
96+
97+
**Community Impact**: A serious violation of community standards, including
98+
sustained inappropriate behavior.
99+
100+
**Consequence**: A temporary ban from any sort of interaction or public
101+
communication with the community for a specified period of time. No public or
102+
private interaction with the people involved, including unsolicited interaction
103+
with those enforcing the Code of Conduct, is allowed during this period.
104+
Violating these terms may lead to a permanent ban.
105+
106+
### 4. Permanent Ban
107+
108+
**Community Impact**: Demonstrating a pattern of violation of community
109+
standards, including sustained inappropriate behavior, harassment of an
110+
individual, or aggression toward or disparagement of classes of individuals.
111+
112+
**Consequence**: A permanent ban from any sort of public interaction within the
113+
community.
68114

69115
## Attribution
70116

71117
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
72-
version 1.4, available
73-
[here](https://www.contributor-covenant.org/version/1/4/code-of-conduct.html).
118+
version 2.1, available at
119+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120+
121+
Community Impact Guidelines were inspired by
122+
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123+
124+
For answers to common questions about this code of conduct, see the FAQ at
125+
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126+
[https://www.contributor-covenant.org/translations][translations].
74127

75128
[homepage]: https://www.contributor-covenant.org
129+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130+
[Mozilla CoC]: https://github.com/mozilla/diversity
131+
[FAQ]: https://www.contributor-covenant.org/faq
132+
[translations]: https://www.contributor-covenant.org/translations

Dockerfile

-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
# Find eligible builder and runner images on Docker Hub. We use Ubuntu/Debian
2-
# instead of Alpine to avoid DNS resolution issues in production.
3-
#
4-
# https://hub.docker.com/r/hexpm/elixir/tags?page=1&name=ubuntu
5-
# https://hub.docker.com/_/ubuntu?tab=tags
6-
#
71
# This file is based on these images:
82
#
93
# - https://hub.docker.com/r/hexpm/elixir/tags - for the build image

lib/cesium_link/accounts/user.ex

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
defmodule CesiumLink.Accounts.User do
2+
@moduledoc """
3+
User schema.
4+
"""
25
use Ecto.Schema
36
import Ecto.Changeset
47

lib/cesium_link/accounts/user_token.ex

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
defmodule CesiumLink.Accounts.UserToken do
2+
@moduledoc """
3+
User tokens for session management.
4+
"""
25
use Ecto.Schema
36
import Ecto.Query
47
alias CesiumLink.Accounts.UserToken

0 commit comments

Comments
 (0)