Skip to content
This repository has been archived by the owner on Nov 9, 2023. It is now read-only.

Commit

Permalink
Fix #1, increase coverage, check changelog
Browse files Browse the repository at this point in the history
[changelog]
fixed: issue where `{:noop}` was returned instead of `:noop`
added: fail Github workflows if changelog has no additions
added: further test coverage for failure cases
  • Loading branch information
OldhamMade committed Feb 9, 2021
1 parent 260b818 commit 8695720
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 2 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Changelog Check

on:
# Trigger this workflow on push (merge) events,
# but ignore the main branch
push:
branches-ignore:
- main

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
changelog:
runs-on: ubuntu-latest

steps:
- name: "[Git] Checkout code"
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: "[Setup] Open /usr/local/bin Permissions"
run: sudo chmod -R a+rwx /usr/local/bin

- name: "[Setup] Cache Dependencies"
id: cache
uses: actions/cache@v2
with:
path: |
/usr/local/bin/git-cl
key: ${{ runner.os }}-release
restore-keys: |
${{ runner.os }}-release
- name: "[Changelog] Install build tools"
uses: fwal/setup-swift@v1
if: steps.cache.outputs.cache-hit != 'true'
with:
swift-version: "5.2"

- name: "[Changelog] Install git-ci"
if: steps.cache.outputs.cache-hit != 'true'
run: |
cd /tmp/
git clone https://github.com/uptech/git-cl.git git-cl
cd ./git-cl
make -j$(nproc)
sudo make install
sudo chmod a+rwx /usr/local/bin/git-cl
cd -
- name: "[Changelog] Fail if no changelog entries"
run: |
git cl unreleased | tail -n +4 | xargs
[ "$(git cl unreleased | tail -n +4 | xargs)" ] || exit 1
5 changes: 5 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ jobs:
sudo chmod a+rwx /usr/local/bin/git-cl
cd -
- name: "[Changelog] Fail if no changelog entries"
run: |
git cl released ${{env.RELEASE_VERSION}}
[ "$(git cl released ${{env.RELEASE_VERSION}} | xargs)" ] || exit 1
- name: "[Changelog] Generate"
run: |
git cl full > CHANGELOG.md
Expand Down
5 changes: 3 additions & 2 deletions lib/mix/tasks/compile.phoenix_sass.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ defmodule Mix.Tasks.Compile.PhoenixSass do
catch
{:error, msg} ->
Logger.error("#{app()}: #{msg}")
{:error, msg}
end

defp process_patterns(pattern) when not is_list(pattern),
Expand Down Expand Up @@ -179,7 +180,7 @@ defmodule Mix.Tasks.Compile.PhoenixSass do
|> Enum.into(%{})
end

defp check_result([]), do: {:noop}
defp check_result([]), do: :noop
defp check_result(transforms) do
results =
transforms
Expand All @@ -204,7 +205,7 @@ defmodule Mix.Tasks.Compile.PhoenixSass do
|> Map.get(:error)
|> warn_of_errors()

{:ok, []}
:ok
end

defp warn_of_errors(nil), do: :noop
Expand Down
24 changes: 24 additions & 0 deletions test/mix/tasks/compile.phoenix_sass_test.exs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
defmodule Mix.Tasks.Compile.PhoenixSassTest do
use ExUnit.Case
import ExUnit.CaptureLog

@fixtures_path "../../fixtures" |> Path.expand(__DIR__)

Expand Down Expand Up @@ -47,6 +48,21 @@ defmodule Mix.Tasks.Compile.PhoenixSassTest do
end

describe "PhoenixSass" do
test ":ok for no sass files" do
File.rm_rf!(Path.join(test_app_dir(), "priv/*"))

assert Mix.Tasks.Phx.Sass.run([]) == :ok
end

test ":error when priv_dir inaccessible" do
File.rm_rf!(test_app_dir())

{result, msg} = Mix.Tasks.Phx.Sass.run([])

assert result == :error
assert msg =~ "priv_dir path invalid or inaccessible:"
end

test "compiles sass to css successfully" do
Mix.Tasks.Phx.Sass.run([])

Expand All @@ -71,6 +87,14 @@ defmodule Mix.Tasks.Compile.PhoenixSassTest do
|> Enum.count()
)
end

test "errors are handled properly" do
Path.join(test_app_dir(), "priv/sass/main.sass")
|> File.write("\n*\n backgroun-color #", [:append])

assert Mix.Tasks.Phx.Sass.run([]) == :ok
assert capture_log(fn -> Mix.Tasks.Phx.Sass.run([]) end) =~ "sass processing errors: 1"
end
end

defp test_app_dir() do
Expand Down
1 change: 1 addition & 0 deletions test/test_helper.exs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ExUnit.start()
ExUnit.configure(capture_log: true)

0 comments on commit 8695720

Please sign in to comment.