Skip to content

Run unit tests in CI only #835

Run unit tests in CI only

Run unit tests in CI only #835

Workflow file for this run

name: Docker Compose CI
on: # yamllint disable-line rule:truthy
pull_request:
branches:
- main
jobs:
changes:
runs-on: ubuntu-latest
outputs:
all: ${{ toJson(steps.changed-files.outputs) }}
steps:
- uses: actions/checkout@v4
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v45
with:
files_yaml_from_source_file: .github/changed_files.yaml
yaml-lint:
runs-on: ubuntu-latest
needs:
- changes
if: fromJson(needs.changes.outputs.all).yaml_all_modified_files
steps:
- uses: actions/checkout@v4
- name: Install 'yamllint'
run: sudo apt-get install -y yamllint
- name: Lint YAML files
run: yamllint -c .github/yamllint_config.yaml .
json-lint:
runs-on: ubuntu-latest
needs:
- changes
if: fromJson(needs.changes.outputs.all).json_all_modified_files
steps:
- uses: actions/checkout@v4
- name: Install 'jsonlint' and 'git'
run: sudo apt install python3-demjson git
- name: Lint JSON files
run: >-
git ls-files -z '*.json' | xargs -0r jsonlint -s --allow=non-portable
shell-lint:
runs-on: ubuntu-latest
needs:
- changes
if: fromJson(needs.changes.outputs.all).sh_all_modified_files
steps:
- uses: actions/checkout@v4
- name: Install 'shellcheck' and 'git'
run: sudo apt install shellcheck git
- name: Lint shell files ([ba]sh scripts)
run: >-
git ls-files -z '*.sh' '*.bash' '*.ksh' '*.bashrc' '*.bash_profile'
'*.bash_login' '*.bash_logout' | xargs -0r shellcheck
javascript-lint:
runs-on: ubuntu-latest
needs:
- changes
if: fromJson(needs.changes.outputs.all).js_all_modified_files
steps:
- uses: actions/checkout@v4
- name: Use Node.js v20
uses: actions/setup-node@v4
with:
node-version: v20
- name: install eslint and default rules
run: npm install eslint @eslint/js --save-dev
- name: Lint javascript files
run: npx eslint --config .github/eslint.config.mjs
- name: Lint html files
run: find . -name "*.html" -o -name ".*.html" | xargs npx --yes htmlhint
python-lint:
runs-on: ubuntu-latest
needs:
- changes
if: fromJson(needs.changes.outputs.all).python_all_modified_files
steps:
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1
with:
args: check --select ALL
check-mkdocs:
runs-on: ubuntu-latest
needs:
- changes
- yaml-lint
- python-lint
- javascript-lint
if: >
!failure()
&& !cancelled()
&& fromJson(needs.changes.outputs.all).docs_all_modified_files
steps:
- uses: SciCatProject/scicatlive/.github/actions/mkdocs-pages@main
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCS_LINK_CHECK: true
TAG: ${{ github.sha }}
docs_folder: ''
test:
runs-on: ubuntu-latest
needs:
- changes
- yaml-lint
- json-lint
- shell-lint
- javascript-lint
- python-lint
- check-mkdocs
if: >
! failure()
&& ! cancelled()
&& fromJson(needs.changes.outputs.all).src_all_modified_files
strategy:
matrix:
BE_VERSION: [v3, v4]
ELASTIC_OR_JOBS_ENABLED: ['', elastic_or_jobs]
LDAP_ENABLED: ['', ldap]
OIDC_ENABLED: ['', oidc]
DEV: ['', dev]
exclude:
- BE_VERSION: ${{
!fromJson(needs.changes.outputs.all).v3_all_modified_files
&& 'v3'
|| (
!fromJson(needs.changes.outputs.all).v4_all_modified_files
&& 'v4'
)
}}
- ELASTIC_OR_JOBS_ENABLED: ${{
!fromJson(needs.changes.outputs.all).elastic_or_jobs_all_modified_files
&& 'elastic_or_jobs' || 'nothing'
}}
- LDAP_ENABLED: ${{
!fromJson(needs.changes.outputs.all).ldap_all_modified_files
&& 'ldap' || 'nothing'
}}
- OIDC_ENABLED: ${{
!fromJson(needs.changes.outputs.all).oidc_all_modified_files
&& 'oidc' || 'nothing'
}}
- DEV: ${{
!fromJson(needs.changes.outputs.all).dev_all_modified_files
&& 'dev' || 'nothing'
}}
steps:
- uses: actions/checkout@v4
- name: Test compose.yaml
run: |-
export JOBS_ENABLED=${{ matrix.ELASTIC_OR_JOBS_ENABLED }}
export ELASTIC_ENABLED=${{ matrix.ELASTIC_OR_JOBS_ENABLED }}
export LDAP_ENABLED=${{ matrix.LDAP_ENABLED }}
export OIDC_ENABLED=${{ matrix.OIDC_ENABLED }}
export BE_VERSION=${{ matrix.BE_VERSION }}
export DEV=${{ matrix.DEV }}
docker compose --profile '*' \
-f compose.yaml ${DEV:+-f .github/compose.dev.test.yaml} \
config