Skip to content

Commit 026528c

Browse files
authored
Merge branch 'Hubs-Foundation:master' into master
2 parents 4343a30 + 4d7b3fd commit 026528c

18 files changed

+502
-73
lines changed
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# Based on the workflow by Brandon Patterson from https://github.com/mikemorran/hubs/blob/master/.github/workflows/ce-build.yml
2+
# Input masking referenced from https://dev.to/leading-edje/masking-input-parameters-in-github-actions-1ci
3+
4+
# Common registry base URLs:
5+
# Docker Hub: docker.io
6+
# GitHub: ghcr.io
7+
8+
name: custom-docker-build-push
9+
10+
on:
11+
workflow_dispatch:
12+
inputs:
13+
Override_Registry_Base_URL:
14+
type: string
15+
Override_Registry_Username:
16+
type: string
17+
Override_Registry_Password:
18+
type: string
19+
Override_Registry_Namespace:
20+
type: string
21+
Override_Image_Tag:
22+
type: string
23+
Override_Dockerfile:
24+
type: string
25+
Override_Code_Path:
26+
type: string
27+
Use_Build_Cache:
28+
type: boolean
29+
default: true
30+
31+
# Add in default values for the inputs plus define any missing variables we need.
32+
# Everything should take their values from env rather than inputs.
33+
env:
34+
Registry_Base_URL: ${{ inputs.Override_Registry_Base_URL || vars.REGISTRY_BASE_URL }}
35+
# Registry_Username: This must be added in each job that needs it.
36+
# Registry_Password: This must be added in each job that needs it.
37+
Registry_Namespace: ${{ inputs.Override_Registry_Namespace || vars.REGISTRY_NAMESPACE }}
38+
Image_Tag: ${{ inputs.Override_Image_Tag || github.ref_name }}
39+
Dockerfile: ${{ inputs.Override_Dockerfile || 'TurkeyDockerfile' }}
40+
Code_Path: ${{ inputs.Override_Code_Path }}
41+
Use_Build_Cache: ${{ inputs.Use_Build_Cache }}
42+
# repo_name: This must be added in each job that needs it.
43+
44+
jobs:
45+
build:
46+
runs-on: ubuntu-latest
47+
48+
steps:
49+
# Env variables
50+
- name: Assign username from secret
51+
if: ${{ inputs.Override_Registry_Username == ''}}
52+
run: |
53+
echo "Registry_Username=${{ secrets.REGISTRY_USERNAME }}" >> "$GITHUB_ENV"
54+
55+
- name: Assign username from input
56+
if: ${{ inputs.Override_Registry_Username != ''}}
57+
run: |
58+
USERNAME=$(jq -r '.inputs.Override_Registry_Username' $GITHUB_EVENT_PATH)
59+
echo ::add-mask::$USERNAME
60+
echo Registry_Username=$USERNAME >> $GITHUB_ENV
61+
62+
- name: Assign password from secret
63+
if: ${{ inputs.Override_Registry_Password == ''}}
64+
run: |
65+
echo "Registry_Password=${{ secrets.REGISTRY_PASSWORD }}" >> "$GITHUB_ENV"
66+
67+
- name: Assign password from input
68+
if: ${{ inputs.Override_Registry_Password != ''}}
69+
run: |
70+
PASSWORD=$(jq -r '.inputs.Override_Registry_Password' $GITHUB_EVENT_PATH)
71+
echo ::add-mask::$PASSWORD
72+
echo Registry_Password=$PASSWORD >> $GITHUB_ENV
73+
74+
- name: Add the repository name as an env variable # Lowercase is forced to prevent errors.
75+
run: |
76+
echo "repo_name=${GITHUB_REPOSITORY#*/}" | tr "[:upper:]" "[:lower:]" >> "$GITHUB_ENV"
77+
78+
# Code
79+
- name: Checkout repository
80+
uses: actions/checkout@v4
81+
with:
82+
path: "./repo"
83+
84+
- name: Use Code_Path for multirepo
85+
if: ${{ env.Code_Path != ''}}
86+
run: |
87+
mkdir ./_repo
88+
cp -rf ./repo/${{ env.Code_Path }}/* ./_repo
89+
rm -rf ./repo
90+
mv ./_repo ./repo
91+
ls ./repo
92+
93+
# Docker
94+
- name: Set up Docker Buildx
95+
uses: docker/setup-buildx-action@v3
96+
with:
97+
install: true
98+
99+
- name: Login to container registry
100+
uses: docker/login-action@v3
101+
with:
102+
registry: ${{ env.Registry_Base_URL }}
103+
username: ${{ env.Registry_Username }}
104+
password: ${{ env.Registry_Password }}
105+
106+
- name: Docker Build and Push (with cache)
107+
if: ${{ fromJSON(env.Use_Build_Cache) == true }}
108+
uses: docker/build-push-action@v6
109+
with:
110+
context: repo/
111+
file: repo/${{ env.Dockerfile }}
112+
tags: ${{ env.Registry_Base_URL }}/${{ env.Registry_Namespace }}/${{ env.repo_name }}:${{ env.Image_Tag }}-latest,${{ env.Registry_Base_URL }}/${{ env.Registry_Namespace }}/${{ env.repo_name }}:${{ env.Image_Tag }}-${{ github.run_number }}
113+
cache-from: type=registry,ref=${{ env.Registry_Base_URL }}/${{ env.Registry_Namespace }}/${{ env.repo_name }}:buildcache
114+
cache-to: type=registry,ref=${{ env.Registry_Base_URL }}/${{ env.Registry_Namespace }}/${{ env.repo_name }}:buildcache,mode=max,image-manifest=true,oci-mediatypes=true
115+
push: true
116+
117+
- name: Docker Build and Push (no cache)
118+
if: ${{ fromJSON(env.Use_Build_Cache) == false }}
119+
uses: docker/build-push-action@v6
120+
with:
121+
context: repo/
122+
file: repo/${{ env.Dockerfile }}
123+
tags: ${{ env.Registry_Base_URL }}/${{ env.Registry_Namespace }}/${{ env.repo_name }}:${{ env.Image_Tag }}-latest,${{ env.Registry_Base_URL }}/${{ env.Registry_Namespace }}/${{ env.repo_name }}:${{ env.Image_Tag }}-${{ github.run_number }}
124+
push: true

.github/workflows/lint-and-test.yml

Lines changed: 143 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,107 @@ name: lint-and-test
33
on: [push, workflow_dispatch]
44

55
jobs:
6-
lint-and-test:
7-
runs-on: ubuntu-20.04
6+
test-current:
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
os:
11+
- 'ubuntu-22.04'
12+
- 'ubuntu-24.04'
13+
14+
runs-on: ${{ matrix.os }}
15+
16+
services:
17+
postgres:
18+
image: postgres:10
19+
env:
20+
POSTGRES_USER: admin
21+
POSTGRES_PASSWORD: admin
22+
options: >-
23+
--health-cmd pg_isready
24+
--health-interval 10s
25+
--health-timeout 5s
26+
--health-retries 5
27+
ports:
28+
- 5432:5432
29+
30+
steps:
31+
- uses: actions/checkout@v4
32+
33+
- uses: erlef/setup-beam@v1
34+
with:
35+
elixir-version: '1.16'
36+
otp-version: '25.3'
37+
38+
- uses: actions/cache@v4
39+
with:
40+
path: |
41+
deps
42+
_build
43+
key: mix-${{ hashFiles('mix.lock') }}
44+
45+
- run: mix local.hex --force
46+
- run: mix local.rebar --force
47+
- run: mix deps.get
48+
- run: mix compile # after fixing warnings, add --warnings-as-errors
49+
- run: mix test
50+
51+
52+
test-matrix:
53+
# if a matrix-job with newer versions passes, advance the current versions!
54+
continue-on-error: true
55+
56+
strategy:
57+
fail-fast: false
58+
matrix:
59+
versions:
60+
# - elixir: '1.14'
61+
# otp: '24.2'
62+
# - elixir: '1.14'
63+
# otp: '24.3'
64+
# - elixir: '1.14'
65+
# otp: '25.3'
66+
#
67+
# - elixir: '1.15'
68+
# otp: '24.3'
69+
# - elixir: '1.15'
70+
# otp: '25.3'
71+
# - elixir: '1.15'
72+
# otp: '26.2'
73+
74+
- elixir: '1.16'
75+
otp: '24.3'
76+
- elixir: '1.16'
77+
otp: '25.3'
78+
- elixir: '1.16'
79+
otp: '26.2'
80+
81+
- elixir: '1.17'
82+
otp: '25.3'
83+
- elixir: '1.17'
84+
otp: '26.2'
85+
- elixir: '1.17'
86+
otp: '27.3'
87+
88+
os:
89+
- 'ubuntu-22.04'
90+
- 'ubuntu-24.04'
91+
92+
exclude:
93+
- versions: # current
94+
elixir: '1.16'
95+
otp: '25.3'
96+
97+
# - versions: # not supported
98+
# elixir: '1.14'
99+
# otp: '24.2'
100+
# os: 'ubuntu-24.04'
101+
- versions: # not supported
102+
elixir: '1.16'
103+
otp: '24.3'
104+
os: 'ubuntu-22.04'
105+
106+
runs-on: ${{ matrix.os }}
8107

9108
services:
10109
postgres:
@@ -21,14 +120,14 @@ jobs:
21120
- 5432:5432
22121

23122
steps:
24-
- uses: actions/checkout@v3
123+
- uses: actions/checkout@v4
25124

26125
- uses: erlef/setup-beam@v1
27126
with:
28-
otp-version: '23.3'
29-
elixir-version: '1.14'
127+
elixir-version: ${{ matrix.versions.elixir }}
128+
otp-version: ${{ matrix.versions.otp }}
30129

31-
- uses: actions/cache@v3.0.2
130+
- uses: actions/cache@v4
32131
with:
33132
path: |
34133
deps
@@ -38,6 +137,43 @@ jobs:
38137
- run: mix local.hex --force
39138
- run: mix local.rebar --force
40139
- run: mix deps.get
41-
- run: mix compile --warnings-as-errors
140+
- run: mix compile # after fixing warnings, add --warnings-as-errors
42141
- run: mix test
142+
143+
144+
pseudo-lint:
145+
continue-on-error: true # TODO: use `mix format` & check in files, then set this false
146+
strategy:
147+
fail-fast: false
148+
matrix:
149+
versions:
150+
- elixir: '1.14'
151+
otp: '24.3'
152+
153+
- elixir: '1.15'
154+
otp: '24.3'
155+
156+
- elixir: '1.16'
157+
otp: '24.3'
158+
159+
- elixir: '1.17'
160+
otp: '25.3'
161+
162+
runs-on: 'ubuntu-24.04'
163+
164+
steps:
165+
- uses: actions/checkout@v4
166+
167+
- uses: erlef/setup-beam@v1
168+
with:
169+
elixir-version: ${{ matrix.versions.elixir }}
170+
otp-version: ${{ matrix.versions.otp }}
171+
172+
- uses: actions/cache@v4
173+
with:
174+
path: |
175+
deps
176+
_build
177+
key: mix-${{ hashFiles('mix.lock') }}
178+
43179
- run: mix format --check-formatted '{lib,priv,test,config}/**/*.{ex,exs}'

.github/workflows/ret-turkey.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
name: ret
1+
name: reticulum
22
on:
33
push:
44
branches:
5-
paths-ignore: ["README.md"]
5+
- 'master'
6+
- 'hotfix/**'
7+
paths-ignore: [".github/**", "guides/**", "README.md", "LICENSE", "CODE_OF_CONDUCT.md"]
68
workflow_dispatch:
79

810
jobs:
911
turkeyGitops:
12+
if: github.repository_owner == 'Hubs-Foundation'
1013
uses: Hubs-Foundation/hubs-ops/.github/workflows/turkeyGitops.yml@master
1114
with:
1215
registry: hubsfoundation

TurkeyDockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# syntax=docker/dockerfile:1
2-
ARG ALPINE_VERSION=3.16.2
3-
ARG ELIXIR_VERSION=1.14.3
4-
ARG ERLANG_VERSION=23.3.4.18
2+
ARG ALPINE_VERSION=3.21.3
3+
ARG ELIXIR_VERSION=1.16.3
4+
ARG ERLANG_VERSION=25.3.2.20
55

66
FROM hexpm/elixir:${ELIXIR_VERSION}-erlang-${ERLANG_VERSION}-alpine-${ALPINE_VERSION} AS base
77
RUN mix do local.hex --force, local.rebar --force

lib/ret/discord_client.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ defmodule Ret.DiscordClient do
122122
(1 <<< 11) => :send_messages,
123123
(1 <<< 12) => :send_tts_messages,
124124
(1 <<< 13) => :manage_messages,
125-
(1 <<< 14) => :emded_links,
125+
(1 <<< 14) => :embed_links,
126126
(1 <<< 15) => :attach_files,
127127
(1 <<< 16) => :read_message_history,
128128
(1 <<< 17) => :mention_everyone,

lib/ret/http_utils.ex

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,4 +175,20 @@ defmodule Ret.HttpUtils do
175175
defp module_config(key) do
176176
Application.get_env(:ret, __MODULE__)[key]
177177
end
178+
179+
def join_smart(enum) do
180+
Enum.reduce(enum, "", fn(x, acc) ->
181+
x = cond do
182+
!x -> nil
183+
is_binary(x) -> String.trim(x)
184+
true -> "#{x}"
185+
end
186+
if x && x != "" do
187+
if acc && acc != "", do: acc <> " — " <> x, else: x
188+
else
189+
acc
190+
end
191+
end)
192+
end
193+
178194
end

lib/ret_web/controllers/file_controller.ex

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ defmodule RetWeb.FileController do
1717

1818
def handle(conn, %{"id" => <<uuid::binary-size(36), ".html">>, "token" => token}, :show) do
1919
case Storage.fetch(uuid, token) do
20-
{:ok, %{"content_type" => content_type}, _stream} ->
20+
{:ok, %{"content_type" => content_type, "content_length" => content_length}, _stream} ->
2121
image_url =
2222
uuid
2323
|> Ret.Storage.uri_for(content_type)
@@ -26,12 +26,23 @@ defmodule RetWeb.FileController do
2626

2727
app_name =
2828
AppConfig.get_cached_config_value("translations|en|app-full-name") ||
29-
AppConfig.get_cached_config_value("translations|en|app-name")
29+
AppConfig.get_cached_config_value("translations|en|app-name") || RetWeb.Endpoint.host()
30+
title = "Photo taken in #{app_name} immersive space"
31+
config = AppConfig.get_config()
3032

3133
conn
3234
|> render("show.html",
3335
image_url: image_url,
34-
app_name: app_name
36+
content_type: content_type |> RetWeb.ContentType.sanitize_content_type(),
37+
content_length: content_length,
38+
title: title,
39+
description_social_media: Ret.HttpUtils.join_smart([
40+
config["translations"]["en"]["app-tagline"],
41+
"powered by Hubs"]),
42+
translations: config["translations"]["en"],
43+
app_name: app_name,
44+
images: config["images"],
45+
root_url: RetWeb.Endpoint.url()
3546
)
3647

3748
{:error, :not_found} ->

0 commit comments

Comments
 (0)