Skip to content

Commit

Permalink
Merge pull request #1 from remoteoss/vp/feat/adapt-pigeon-to-remote-n…
Browse files Browse the repository at this point in the history
…eeds

feat: fix deprecation warnings and unmatched clause
  • Loading branch information
valerio-pizzichini authored Aug 28, 2024
2 parents 05fe855 + fac5192 commit b03f79e
Show file tree
Hide file tree
Showing 28 changed files with 62 additions and 2,120 deletions.
10 changes: 10 additions & 0 deletions .env.test.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export FCM_PROJECT_ID="your-firebase-project-id"
export FCM_SERVICE_ACCOUNT_JSON=$(cat /path/to/service/account/json)

export APNS_KEY_UNENCRYPTED=$(cat /path/to/apns/key-unencrypted.p8)
export APNS_KEY_IDENTIFIER="your-apple-key-identifier"
export APNS_TEAM_ID="your-apple-team-id"
export APNS_TOPIC="com.your.project.topic"

export VALID_APNS_TOKEN="a-valid-apple-device-token"
export VALID_GCM_REG_ID="a-valid-android-device-token"
25 changes: 10 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ jobs:
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: "1.14.3"
otp-version: "24.3"
elixir-version: "1.15.5"
otp-version: "26.0.2"
- name: Restore dependencies cache
uses: actions/cache@v3
with:
Expand All @@ -53,8 +53,8 @@ jobs:
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: "1.14.3"
otp-version: "24.3"
elixir-version: "1.15.5"
otp-version: "26.0.2"
- name: Restore dependencies cache
uses: actions/cache@v3
with:
Expand All @@ -65,17 +65,12 @@ jobs:
run: mix deps.get
- name: Run tests
env:
ADM_OAUTH2_CLIENT_ID: ${{ secrets.ADM_OAUTH2_CLIENT_ID }}
ADM_OAUTH2_CLIENT_SECRET: ${{ secrets.ADM_OAUTH2_CLIENT_SECRET }}
APNS_AUTH_KEY_P8: ${{ secrets.APNS_AUTH_KEY_P8 }}
APNS_CERT: ${{ secrets.APNS_CERT }}
APNS_JWT_KEY_IDENTIFIER: ${{ secrets.APNS_JWT_KEY_IDENTIFIER }}
APNS_JWT_TEAM_ID: ${{ secrets.APNS_JWT_TEAM_ID }}
APNS_KEY_IDENTIFIER: ${{ secrets.APNS_KEY_IDENTIFIER }}
APNS_TEAM_ID: ${{ secrets.APNS_TEAM_ID }}
APNS_KEY_UNENCRYPTED: ${{ secrets.APNS_KEY_UNENCRYPTED }}
APNS_TOPIC: ${{ secrets.APNS_TOPIC }}
FCM_PROJECT: ${{ secrets.FCM_PROJECT }}
APNS_TOPIC: ${{ vars.APNS_TOPIC }}
FCM_PROJECT_ID: ${{ secrets.FCM_PROJECT_ID }}
FCM_SERVICE_ACCOUNT_JSON: ${{ secrets.FCM_SERVICE_ACCOUNT_JSON }}
GCM_KEY: ${{ secrets.GCM_KEY }}
VALID_APNS_TOKEN: ${{ secrets.VALID_APNS_TOKEN }}
VALID_GCM_REG_ID: ${{ secrets.VALID_GCM_REG_ID }}
VALID_APNS_TOKEN: ${{ vars.VALID_APNS_TOKEN }}
VALID_GCM_REG_ID: ${{ vars.VALID_GCM_REG_ID }}
run: mix test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ scratchpad.txt
.idea
pigeon.iml
.envrc

.env.test
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ Unit tests can be run with `mix test` or `mix coveralls.html`. Environment varia
various credentials. See [config/test.exs](https://github.com/codedge-llc/pigeon/blob/master/config/test.exs)
for the full list.

```sh
cp .env.test.example .env.test
# Update the environment values with your project ones
source .env.test
```

### Formatting

This project uses Elixir's `mix format` and [Prettier](https://prettier.io) for formatting.
Expand Down
24 changes: 8 additions & 16 deletions config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,23 @@ config :pigeon, :test,
valid_apns_token: System.get_env("VALID_APNS_TOKEN"),
valid_fcm_reg_id: System.get_env("VALID_GCM_REG_ID")

config :pigeon, PigeonTest.ADM,
adapter: Pigeon.ADM,
client_id: System.get_env("ADM_OAUTH2_CLIENT_ID"),
client_secret: System.get_env("ADM_OAUTH2_CLIENT_SECRET")

config :pigeon, PigeonTest.APNS,
adapter: Pigeon.APNS,
cert: System.get_env("APNS_CERT"),
key: System.get_env("APNS_KEY_UNENCRYPTED"),
mode: :dev
key_identifier: System.get_env("APNS_KEY_IDENTIFIER"),
team_id: System.get_env("APNS_TEAM_ID"),
mode: :prod

config :pigeon, PigeonTest.APNS.JWT,
adapter: Pigeon.APNS,
key: System.get_env("APNS_AUTH_KEY_P8"),
key_identifier: System.get_env("APNS_JWT_KEY_IDENTIFIER"),
team_id: System.get_env("APNS_JWT_TEAM_ID"),
mode: :dev

config :pigeon, PigeonTest.LegacyFCM,
adapter: Pigeon.LegacyFCM,
key: System.get_env("GCM_KEY")
key: System.get_env("APNS_KEY_UNENCRYPTED"),
key_identifier: System.get_env("APNS_KEY_IDENTIFIER"),
team_id: System.get_env("APNS_TEAM_ID"),
mode: :prod

config :pigeon, PigeonTest.FCM,
adapter: Pigeon.FCM,
project_id: System.get_env("FCM_PROJECT"),
project_id: System.get_env("FCM_PROJECT_ID"),
service_account_json: System.get_env("FCM_SERVICE_ACCOUNT_JSON")

config :pigeon, PigeonTest.Sandbox, adapter: Pigeon.Sandbox
3 changes: 2 additions & 1 deletion lib/pigeon/adapter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ defmodule Pigeon.Adapter do
@doc """
Invoked to handle all other messages.
"""
@callback handle_info(term, term) :: {:noreply, term}
@callback handle_info(term, term) ::
{:noreply, term} | {:stop, reason :: term}

@doc """
Invoked to handle push notifications.
Expand Down
Loading

0 comments on commit b03f79e

Please sign in to comment.