From fb1d0fc00bf090dae6924a7fb4da589690ab75eb Mon Sep 17 00:00:00 2001 From: Omar Al-Ithawi Date: Thu, 8 Apr 2021 11:07:11 +0300 Subject: [PATCH] Initial tox and gitbub actions: avoid getting stale css --- .github/workflows/tests.yml | 26 ++++++++++++++++++++++++++ .gitignore | 1 + README.md | 12 ++++++++++++ scripts/compile.sh | 5 +++++ scripts/verify.sh | 16 ++++++++++++++++ tox.ini | 19 +++++++++++++++++++ 6 files changed, 79 insertions(+) create mode 100644 .github/workflows/tests.yml create mode 100644 README.md create mode 100644 scripts/compile.sh create mode 100644 scripts/verify.sh create mode 100644 tox.ini diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000..fab446e1 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,26 @@ +name: customer themes + +on: + push: + branches: ['juniper/tahoe'] + pull_request: + +jobs: + test: + runs-on: ubuntu-18.04 + strategy: + matrix: + python-version: [3.8] + tox-env: + - verify + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + pip install tox + - name: Test with tox + run: tox -e ${{ matrix.tox-env }} diff --git a/.gitignore b/.gitignore index e43b0f98..ae998703 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .DS_Store +.tox diff --git a/README.md b/README.md new file mode 100644 index 00000000..b28a8091 --- /dev/null +++ b/README.md @@ -0,0 +1,12 @@ +# Customer-specific theme +This repo has the customer themes. + +## How to: Compile the `amc-specific.scss` file + +On your devstack run: + +``` +$ tox -e compile +``` + +Commit the changes and make a pull request. diff --git a/scripts/compile.sh b/scripts/compile.sh new file mode 100644 index 00000000..91cd0255 --- /dev/null +++ b/scripts/compile.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +set -ex + +# Run via `tox -e compile` +pysassc cms/static/sass/amc-specific.scss cms/static/css/amc-specific.css diff --git a/scripts/verify.sh b/scripts/verify.sh new file mode 100644 index 00000000..e5a51a83 --- /dev/null +++ b/scripts/verify.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +set -e + +# Run this script via `$ tox -e verify` +if git diff --no-ext-diff --quiet --exit-code; then + echo "Success: The CSS file is in sync with the SCSS file." +else + echo "Error: CSS is out of sync" + echo "=== Start: Git diff ===" + git --no-pager diff + echo "=== End: Git diff ===" + echo 'Error: The CSS file is out of sync with the SCSS file.' + echo 'The git diff above shows the difference.' + echo 'Please use "$ tox -e compile" locally to compile the SCSS file.' + exit 1 +fi diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..9aa55c3f --- /dev/null +++ b/tox.ini @@ -0,0 +1,19 @@ +[tox] +envlist = compile,verify +skipsdist = True + +[testenv] +basepython=python3 +deps = libsass==0.20.1 +allowlist_externals = + bash + +[testenv:compile] +commands = + bash {toxinidir}/scripts/compile.sh + +[testenv:verify] +commands = + bash {toxinidir}/scripts/compile.sh + bash {toxinidir}/scripts/verify.sh +