Skip to content

Commit

Permalink
Only install dependencies as a part of initialization when needed
Browse files Browse the repository at this point in the history
This ensures that we do not keep any docker containers running for
developers who do not want/use them.

Sources/generates ensures that nothing is installed needlessly.

Instead we run dev:reset when starting cms development. This also means
that we have to move cms:link from a dependecy to a command since we
cannot ensure that we have a running CMS instance beforehand.

This also means that we have to start the CMS for development explicitly
when running tests. We do not use dev:* commands here as they start
running watch processes. Instead we run their subtasks individually.

Since there is no reset anymore we cannot test it either.
  • Loading branch information
kasperg committed Dec 5, 2023
1 parent 91fcef8 commit c415f8a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 26 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Initialize environment
run: "task init ${{ env.TASK_OUTPUT }}"
- name: Prepare CMS for development
run: "task cms:dev ${{ env.TASK_OUTPUT }}"
- name: Link Design system to React components
run: "task react:link ${{ env.TASK_OUTPUT }}"
- name: Link Design system and React components to CMS
Expand Down Expand Up @@ -98,8 +100,6 @@ jobs:
# a difference. Reverse this using !.
run: |
! diff ${{ runner.temp }}/react/version.before.json ${{ runner.temp }}/react/version.after.json
- name: Reset environment
run: "task reset ${{ env.TASK_OUTPUT }}"
- name: Setup tmate session to support debugging if enabled
if: runner.debug == '1'
uses: mxschmitt/action-tmate@v3
Expand Down
63 changes: 39 additions & 24 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tasks:
- react:clone
- cms:clone
cmds:
- task: reset
- task: install

cleanup:
cmds:
Expand All @@ -29,17 +29,27 @@ tasks:
- task: cleanup
- task: init

reset:
summary: Reset environment. This is useful when switching between tasks, branches etc.
install:
summary: (Re)install all dependencies.
deps:
- design-system:reset
- react:reset
- cms:reset
- design-system:install
- react:install
- cms:install

design-system:clone:
cmds:
- git clone https://github.com/danskernesdigitalebibliotek/dpl-design-system design-system

design-system:install:
dir: design-system
sources:
- package.json
- yarn.lock
generates:
- node_modules/*
cmds:
- yarn install

design-system:link:
deps:
- design-system:build
Expand Down Expand Up @@ -70,18 +80,23 @@ tasks:
cmds:
- yarn dev

design-system:reset:
dir: design-system
cmds:
- yarn install

react:clone:
cmds:
- git clone https://github.com/danskernesdigitalebibliotek/dpl-react react
# Set project name to avoid conflicts with single checkouts.
- cp react/.env.example react/.env
- echo "COMPOSE_PROJECT_NAME={{.REACT_COMPOSE_PROJECT_NAME}}" >> react/.env

react:install:
dir: react
sources:
- package.json
- yarn.lock
generates:
- node_modules/*
cmds:
- yarn install

react:link:
dir: react
deps:
Expand Down Expand Up @@ -116,17 +131,21 @@ tasks:
cmds:
- yarn dev

react:reset:
dir: react
cmds:
- yarn install

cms:clone:
cmds:
- git clone https://github.com/danskernesdigitalebibliotek/dpl-cms cms
# Set project name to avoid conflicts with single checkouts.
- sed "s|COMPOSE_PROJECT_NAME=dpl-cms|COMPOSE_PROJECT_NAME={{.CMS_COMPOSE_PROJECT_NAME}}|g" <cms/.env.example >cms/.env

cms:install:
dir: cms
sources:
- composer.lock
generates:
- vendor/*
cmds:
- task dev:cli -- composer install

cms:link:
dir: cms
deps:
Expand All @@ -140,13 +159,7 @@ tasks:

cms:dev:
dir: cms
deps:
- cms:link
cmds:
- task dev:start

cms:reset:
dir: cms
run: once
cmds:
- task dev:reset

Expand All @@ -157,8 +170,9 @@ tasks:
- task: react:dev

dev:cms:
deps:
cmds:
- task: cms:dev
- task: cms:link

dev:cms-react:
deps:
Expand All @@ -168,3 +182,4 @@ tasks:
# run it on port 80 by default. To allow the user to reply we have to run
# it as a separate task instead of a dependency.
- task: react:dev
- task: cms:link

0 comments on commit c415f8a

Please sign in to comment.