Skip to content

Commit

Permalink
Merge pull request #42 from mitodl/jkachel/add-ci-actions
Browse files Browse the repository at this point in the history
Adds some CI actions back in
  • Loading branch information
jkachel authored Jan 22, 2024
2 parents 758f887 + dd39b15 commit fbe56bb
Show file tree
Hide file tree
Showing 7 changed files with 570 additions and 313 deletions.
177 changes: 0 additions & 177 deletions .github-ex/workflows/ci.yml

This file was deleted.

80 changes: 80 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: CI
on: [push]
jobs:
python-tests:
runs-on: ubuntu-latest

services:
# Label used to access the service container
db:
# Docker Hub image
image: postgres:16
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres # pragma: allowlist secret
POSTGRES_DB: postgres
ports:
- 5432:5432

redis:
image: redis:5.0.14
ports:
- 6379:6379

steps:
- uses: actions/checkout@v3

- name: update apt
run: sudo apt-get update -y

- name: Apt install
run: cat Aptfile | sudo xargs apt-get install

- name: Install poetry
uses: snok/install-poetry@v1
with:
version: 1.5.1
virtualenvs-create: true
virtualenvs-in-project: true

- uses: actions/setup-python@v4
with:
python-version: "3.12.1"
cache: "poetry"

- name: Validate lockfile
run: poetry lock --check

- name: Install dependencies
run: poetry install --no-interaction

- name: Lint
run: poetry run ruff --extend-ignore=D1 $(git ls-files '*.py')

- name: Tests
run: |
export MEDIA_ROOT="$(mktemp -d)"
./scripts/test/python_tests.sh
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres # pragma: allowlist secret
CELERY_TASK_ALWAYS_EAGER: "True"
CELERY_BROKER_URL: redis://localhost:6379/4
CELERY_RESULT_BACKEND: redis://localhost:6379/4
MITOL_UE_COOKIE_NAME: "mitolue"
MITOL_UE_COOKIE_DOMAIN: "odl.local"
MITOL_UE_BASE_URL: "http://localhost:8073"
MITOL_UE_HOSTNAME: "ue.odl.local"
MITOL_UE_JWT_SECRET: ""
MITOL_UE_USE_S3: "False"
MITOL_UE_DB_DISABLE_SSL: "True"

- name: Upload coverage to CodeCov
uses: codecov/[email protected]
with:
file: ./coverage.xml
74 changes: 38 additions & 36 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
# A bunch of frontend related stuff is commented out here - this is because we don't
# have a frontend yet.
ci:
skip:
- prettier-django
Expand All @@ -19,22 +21,22 @@ repos:
- id: check-merge-conflict
- id: check-toml
- id: debug-statements
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.3
hooks:
- id: prettier
types_or:
[javascript, jsx, ts, tsx, json, scss, sass, css, yaml, markdown]
args:
- --no-config
- --no-semi
- id: prettier
alias: prettier-django
name: prettier-django
types: [html]
additional_dependencies:
- prettier
- prettier-plugin-django-alpine
# - repo: https://github.com/pre-commit/mirrors-prettier
# rev: v3.0.3
# hooks:
# - id: prettier
# types_or:
# [javascript, jsx, ts, tsx, json, scss, sass, css, yaml, markdown]
# args:
# - --no-config
# - --no-semi
# - id: prettier
# alias: prettier-django
# name: prettier-django
# types: [html]
# additional_dependencies:
# - prettier
# - prettier-plugin-django-alpine
- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.7.0-1
hooks:
Expand Down Expand Up @@ -73,26 +75,26 @@ repos:
- id: ruff-format
- id: ruff
args: [--extend-ignore=D1, --fix]
- repo: local
hooks:
- id: eslint
name: eslint
description: "Lint JS/TS files and apply automatic fixes"
entry: npx eslint --fix
language: node
types_or: [javascript, jsx, ts, tsx]
args: []
exclude: "(node_modules/|.yarn/)"
require_serial: false
- id: scss-lint
name: scss-lint
description: "Lint SCSS files"
entry: npx stylelint --allow-empty-input --fix
language: node
types: [scss]
args: []
exclude: node_modules/
require_serial: false
# - repo: local
# hooks:
# - id: eslint
# name: eslint
# description: "Lint JS/TS files and apply automatic fixes"
# entry: npx eslint --fix
# language: node
# types_or: [javascript, jsx, ts, tsx]
# args: []
# exclude: "(node_modules/|.yarn/)"
# require_serial: false
# - id: scss-lint
# name: scss-lint
# description: "Lint SCSS files"
# entry: npx stylelint --allow-empty-input --fix
# language: node
# types: [scss]
# args: []
# exclude: node_modules/
# require_serial: false
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.9.0.6
hooks:
Expand Down
Loading

0 comments on commit fbe56bb

Please sign in to comment.