Skip to content

Commit

Permalink
Merge branch 'main' into cn-custom-elements
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Nelson committed Jan 12, 2025
2 parents 1964cf0 + 4835a51 commit ad7dc69
Show file tree
Hide file tree
Showing 213 changed files with 17,264 additions and 21,114 deletions.
28 changes: 17 additions & 11 deletions .github/single-file-samples/main.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ Application.put_env(:sample, Example.Endpoint,
secret_key_base: String.duplicate("a", 64)
)

Mix.install([
{:plug_cowboy, "~> 2.5"},
{:jason, "~> 1.0"},
{:phoenix, "~> 1.7"},
# please test your issue using the latest version of LV from GitHub!
{:phoenix_live_view, github: "phoenixframework/phoenix_live_view", branch: "main", override: true},
])
Mix.install(
[
{:plug_cowboy, "~> 2.5"},
{:jason, "~> 1.0"},
{:phoenix, "~> 1.7"},
# please test your issue using the latest version of LV from GitHub!
{:phoenix_live_view,
github: "phoenixframework/phoenix_live_view", branch: "main", override: true}
],
force: true
)

# build the LiveView JavaScript assets (this needs mix and npm available in your path!)
path = Phoenix.LiveView.__info__(:compile)[:source] |> Path.dirname() |> Path.join("../")
Expand All @@ -32,8 +36,10 @@ defmodule Example.HomeLive do

def render("live.html", assigns) do
~H"""
<script src="/assets/phoenix/phoenix.js"></script>
<script src="/assets/phoenix_live_view/phoenix_live_view.js"></script>
<script src="/assets/phoenix/phoenix.js">
</script>
<script src="/assets/phoenix_live_view/phoenix_live_view.js">
</script>
<%!-- uncomment to use enable tailwind --%>
<%!-- <script src="https://cdn.tailwindcss.com"></script> --%>
<script>
Expand All @@ -43,13 +49,13 @@ defmodule Example.HomeLive do
<style>
* { font-size: 1.1em; }
</style>
<%= @inner_content %>
{@inner_content}
"""
end

def render(assigns) do
~H"""
<%= @count %>
{@count}
<button phx-click="inc">+</button>
<button phx-click="dec">-</button>
"""
Expand Down
28 changes: 17 additions & 11 deletions .github/single-file-samples/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ Application.put_env(:phoenix, Example.Endpoint,
secret_key_base: String.duplicate("a", 64)
)

Mix.install([
{:plug_cowboy, "~> 2.5"},
{:jason, "~> 1.0"},
{:phoenix, "~> 1.7"},
# please test your issue using the latest version of LV from GitHub!
{:phoenix_live_view, github: "phoenixframework/phoenix_live_view", branch: "main", override: true},
{:floki, ">= 0.30.0"}
])
Mix.install(
[
{:plug_cowboy, "~> 2.5"},
{:jason, "~> 1.0"},
{:phoenix, "~> 1.7"},
# please test your issue using the latest version of LV from GitHub!
{:phoenix_live_view,
github: "phoenixframework/phoenix_live_view", branch: "main", override: true},
{:floki, ">= 0.30.0"}
],
force: true
)

ExUnit.start()

Expand All @@ -30,16 +34,18 @@ defmodule Example.HomeLive do

def render("live.html", assigns) do
~H"""
<script src="/assets/phoenix/phoenix.js"></script>
<script src="/assets/phoenix_live_view/phoenix_live_view.js"></script>
<script src="/assets/phoenix/phoenix.js">
</script>
<script src="/assets/phoenix_live_view/phoenix_live_view.js">
</script>
<script>
let liveSocket = new window.LiveView.LiveSocket("/live", window.Phoenix.Socket)
liveSocket.connect()
</script>
<style>
* { font-size: 1.1em; }
</style>
<%= @inner_content %>
{@inner_content}
"""
end

Expand Down
61 changes: 61 additions & 0 deletions .github/workflows/assets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Assets

on:
push:
branches:
- main
- "v*.*"

jobs:
build:
runs-on: ubuntu-22.04
env:
elixir: 1.18.1
otp: 27.2
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: ${{ env.elixir }}
otp-version: ${{ env.otp }}

- name: Restore deps and _build cache
uses: actions/cache@v4
with:
path: |
deps
_build
key: ${{ runner.os }}-mix-${{ env.elixir }}-${{ env.otp }}-${{ hashFiles('**/mix.lock') }}-dev
restore-keys: |
${{ runner.os }}-mix-${{ env.elixir }}-${{ env.otp }}-
- name: Install Dependencies
run: mix deps.get --only dev

- name: Set up Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x

- name: Restore npm cache
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install npm dependencies
run: npm ci

- name: Build assets
run: mix assets.build

- name: Push updated assets
id: push_assets
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Update assets
file_pattern: priv/static
153 changes: 80 additions & 73 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
include:
- elixir: 1.13.4
- elixir: 1.14.5
otp: 24.3

- elixir: 1.15.4
Expand All @@ -23,78 +23,82 @@ jobs:
otp: 26.2

# update coverage report as well
- elixir: 1.17.2
otp: 27.0
- elixir: 1.18.1
otp: 27.2
lint: lint

# run against latest Elixir to catch warnings early
- elixir: main
otp: maint-27

runs-on: ubuntu-latest

steps:
- name: Install inotify-tools
run: |
sudo apt update
sudo apt install -y inotify-tools
- name: Checkout
uses: actions/checkout@v4

- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: ${{ matrix.elixir }}
otp-version: ${{ matrix.otp }}

- name: Restore deps and _build cache
uses: actions/cache@v4
with:
path: |
deps
_build
key: deps-${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
deps-${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}
- name: Install dependencies
run: mix deps.get --only test

- name: Remove compiled application files
run: mix clean

- name: Compile dependencies
run: mix compile
if: ${{ !matrix.lint }}
env:
MIX_ENV: test

- name: Compile & lint dependencies
run: mix compile --warnings-as-errors
if: ${{ matrix.lint }}
env:
MIX_ENV: test

- name: Check if formatted
run: mix format --check-formatted
if: ${{ matrix.lint }}
env:
MIX_ENV: test

- name: Run tests
run: mix test --cover --export-coverage default

- uses: actions/upload-artifact@v4
if: always()
with:
name: mix-test-coverage-${{ matrix.otp }}-${{ matrix.elixir }}
path: cover/default.coverdata
retention-days: 7
- name: Install inotify-tools
run: |
sudo apt update
sudo apt install -y inotify-tools
- name: Checkout
uses: actions/checkout@v4

- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: ${{ matrix.elixir }}
otp-version: ${{ matrix.otp }}

- name: Restore deps and _build cache
uses: actions/cache@v4
with:
path: |
deps
_build
key: deps-${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
deps-${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}
- name: Install dependencies
run: mix deps.get --only test

- name: Remove compiled application files
run: mix clean

- name: Compile dependencies
run: mix compile
if: ${{ !matrix.lint }}
env:
MIX_ENV: test

- name: Compile & lint dependencies
run: mix compile --warnings-as-errors
if: ${{ matrix.lint }} or ${{ matrix.elixir == 'main' }}
env:
MIX_ENV: test

- name: Check if formatted
run: mix format --check-formatted
if: ${{ matrix.lint }}
env:
MIX_ENV: test

- name: Run tests
run: mix test --cover --export-coverage default

- uses: actions/upload-artifact@v4
if: always()
with:
name: mix-test-coverage-${{ matrix.otp }}-${{ matrix.elixir }}
path: cover/default.coverdata
retention-days: 7

npm_test:
name: npm test

strategy:
matrix:
include:
- elixir: 1.17.2
otp: 27.0
- elixir: 1.18.1
otp: 27.2

runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -134,13 +138,16 @@ jobs:
${{ runner.os }}-node-
- name: npm install and test
run: npm run js:test
run: npm run setup && npm run js:test

- name: eslint
run: npx eslint

- uses: actions/upload-artifact@v4
if: always()
with:
name: js-unit-coverage
path: assets/coverage/
path: coverage/
retention-days: 7

e2e_test:
Expand All @@ -149,12 +156,12 @@ jobs:
strategy:
matrix:
include:
- elixir: 1.17.2
otp: 27.0
- elixir: 1.18.1
otp: 27.2

runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:v1.47.1-jammy
image: mcr.microsoft.com/playwright:v1.49.1-jammy
env:
ImageOS: ubuntu22
HOME: /root
Expand Down Expand Up @@ -211,7 +218,7 @@ jobs:
name: e2e-test-results
path: test/e2e/test-results/
retention-days: 7

- uses: actions/upload-artifact@v4
if: always()
with:
Expand All @@ -232,14 +239,14 @@ jobs:
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: 1.17.2
otp-version: 27.0
elixir-version: 1.18.1
otp-version: 27.2

- name: Download mix unit coverage
uses: actions/download-artifact@v4
with:
# This needs to be updated when changing the test matrix
name: mix-test-coverage-27-1.17.2
name: mix-test-coverage-27.2-1.18.1
path: cover/

- name: Download mix e2e coverage
Expand All @@ -254,9 +261,9 @@ jobs:
path: |
deps
_build
key: deps-${{ runner.os }}-27-1.17.2-${{ hashFiles('**/mix.lock') }}
key: deps-${{ runner.os }}-27.2-1.18.1-${{ hashFiles('**/mix.lock') }}
restore-keys: |
deps-${{ runner.os }}-27-1.17.2
deps-${{ runner.os }}-27.2-1.18.1
- name: Generate mix coverage report
run: mix test.coverage
Expand All @@ -265,7 +272,7 @@ jobs:
uses: actions/download-artifact@v4
with:
name: js-unit-coverage
path: assets/coverage/
path: coverage/

- name: Download e2e-test-results artifact
uses: actions/download-artifact@v4
Expand Down
Loading

0 comments on commit ad7dc69

Please sign in to comment.