Skip to content

Commit

Permalink
feat: add lfs checkout for django projects (#55)
Browse files Browse the repository at this point in the history
* feat: add lfs checkout for django projects

* ci: add GIT LFS installation

* fix: add lfs pull

* fix: add lfs workaround

* fix: add lfs workaround

* fix: add lfs workaround

* fix: add lfs workaround

* fix: add lfs workaround

* fix: add dynamic LFS workaround repo path
  • Loading branch information
alessandro-mariotti-zupit authored Nov 14, 2023
1 parent 5e27c00 commit 1afc180
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 1 deletion.
22 changes: 22 additions & 0 deletions .github/workflows/django-step-lint-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ on:
required: false
type: string
default: ""
ENABLE_LFS:
required: false
type: boolean
default: false
# Workaround for https://github.com/actions/checkout/issues/1169
LFS_REPO_PATH:
required: false
type: string
default: ""

env: "${{secrets}}"

Expand All @@ -48,8 +57,21 @@ jobs:
image: redis

steps:
- name: Install prerequisites
if: ${{ inputs.ENABLE_LFS == true }}
run: apt-get update && apt-get install -y git-lfs
- name: Checkout code
uses: actions/checkout@v3
if: ${{ inputs.ENABLE_LFS == true }}
with:
lfs: 'true'
- uses: actions/checkout@v3
if: ${{ inputs.ENABLE_LFS == false }}
- run: git config --global --add safe.directory /__w/mobygis-waterjade/mobygis-waterjade
if: ${{ inputs.ENABLE_LFS == true }}
- name: Checkout LFS objects
if: ${{ inputs.ENABLE_LFS == true }}
run: git lfs pull
- name: Setup
run: ${{ inputs.SETUP_COMMANDS }}
- name: Install dependencies
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/django-step-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ on:
required: false
type: string
default: ""
ENABLE_LFS:
required: false
type: boolean
default: false

# Workaround for https://github.com/actions/checkout/issues/1169
LFS_REPO_PATH:
required: false
type: string
default: ""

env: "${{secrets}}"

Expand All @@ -47,7 +57,20 @@ jobs:
image: redis

steps:
- name: Install prerequisites
if: ${{ inputs.ENABLE_LFS == true }}
run: apt-get update && apt-get install -y git-lfs
- uses: actions/checkout@v3
if: ${{ inputs.ENABLE_LFS == true }}
with:
lfs: 'true'
- uses: actions/checkout@v3
if: ${{ inputs.ENABLE_LFS == false }}
- run: git config --global --add safe.directory ${{ inputs.LFS_REPO_PATH }}
if: ${{ inputs.ENABLE_LFS == true }}
- name: Checkout LFS objects
if: ${{ inputs.ENABLE_LFS == true }}
run: git lfs pull
- name: Setup
run: ${{ inputs.SETUP_COMMANDS }}
- name: Install dependencies
Expand Down
14 changes: 13 additions & 1 deletion .github/workflows/django-workflow-common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,15 @@ on:
required: false
type: string
default: ""

ENABLE_LFS:
required: false
type: boolean
default: false
# Workaround for https://github.com/actions/checkout/issues/1169
LFS_REPO_PATH:
required: false
type: string
default: ""
jobs:
django-lint-check:
uses:
Expand All @@ -45,6 +53,8 @@ jobs:
RUN: ${{inputs.RUN}}
DJANGO_MIGRATIONS_CHECK_APPS: ${{inputs.DJANGO_MIGRATIONS_CHECK_APPS}}
SETUP_COMMANDS: ${{inputs.SETUP_COMMANDS}}
ENABLE_LFS: ${{inputs.ENABLE_LFS}}
LFS_REPO_PATH: ${{inputs.LFS_REPO_PATH}}
secrets: inherit

django-tests:
Expand All @@ -57,4 +67,6 @@ jobs:
COVERAGE_ARTIFACT_NAME: ${{ inputs.COVERAGE_ARTIFACT_NAME }}
RUN: ${{inputs.RUN}}
SETUP_COMMANDS: ${{ inputs.SETUP_COMMANDS }}
ENABLE_LFS: ${{inputs.ENABLE_LFS}}
LFS_REPO_PATH: ${{inputs.LFS_REPO_PATH}}
secrets: inherit
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,8 @@ In addition, it is possible to specify this optional input:
- **RUN**: Whether to run all the inside workflows or not. This is useful when you want to skip checks since the code didn't change. By default, it is **true**.
- **DJANGO_MIGRATIONS_CHECK_APPS**: The Django apps on which to run migration checks.
- **SETUP_COMMANDS**: Allow to execute commands before the download of the dependencies. Useful to install packages required for Python dependencies.
- **ENABLE_LFS**: To enable Git LFS support on checkout
- **LFS_REPO_PATH**: Required when ENABLE_LFS is true. Workaround for https://github.com/actions/checkout/issues/1169. Set to "/__w/repo-name/repo-name"

This is an example to show how data should be formatted.

Expand Down

0 comments on commit 1afc180

Please sign in to comment.