From d1b01ff61602940ed1efae42aad5fdda89e383a2 Mon Sep 17 00:00:00 2001 From: Colin Rotherham Date: Thu, 20 Feb 2025 13:14:56 +0000 Subject: [PATCH] Add tests for Sass versions Inspired by https://github.com/alphagov/govuk-frontend/blob/main/.github/workflows/sass.yaml --- .github/workflows/sass.yaml | 63 +++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/sass.yaml diff --git a/.github/workflows/sass.yaml b/.github/workflows/sass.yaml new file mode 100644 index 000000000..688b0332e --- /dev/null +++ b/.github/workflows/sass.yaml @@ -0,0 +1,63 @@ +name: Sass + +on: pull_request + +jobs: + sass: + name: Dart Sass ${{ matrix.package-version }} + runs-on: ubuntu-22.04 + + strategy: + fail-fast: false + + matrix: + package-version: + # Release without major deprecations + - 1.77.6 + + # Release with `mixed-decls` deprecated + - 1.77.7 + + # Release with `import` deprecated + - 1.80.0 + + # Dart Sass latest major version + - latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version-file: .nvmrc + cache: 'npm' + + - name: Install package + run: | + npm install -g sass@${{ matrix.package-version }} + sass --version + + - name: Check compilation + run: | + mkdir -p .tmp + sass packages/nhsuk.scss > .tmp/check.css + + - name: Check load paths + run: | + mkdir -p .tmp + sh -c 'echo "@import "\""nhsuk"\"";" | sass --stdin --load-path packages > .tmp/check1.css' + sh -c 'echo "@use "\""nhsuk"\"" as *;" | sass --stdin --load-path packages > .tmp/check2.css' + sh -c 'echo "@forward "\""nhsuk"\"";" | sass --stdin --load-path packages > .tmp/check3.css' + + - name: Check '@use' syntax + run: sh -c 'echo "@use "\""nhsuk"\"" as *;" | sass --stdin --load-path packages > /dev/null' + + # Check output for uncompiled Sass + - name: Check output + run: | + ! grep "\$nhsuk-" .tmp/check.css + ! grep "\$nhsuk-" .tmp/check1.css + ! grep "\$nhsuk-" .tmp/check2.css + ! grep "\$nhsuk-" .tmp/check3.css