From 1129ef6304a5bf2ae155e922278859e336a61eec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Sch=C3=BCller?= Date: Tue, 13 Aug 2024 13:48:57 +0200 Subject: [PATCH] Makefile: fix inconsistent builds and help running scripts locally --- .github/workflows/deploy.yml | 4 +-- .github/workflows/protect-readmes.yml | 2 +- .github/workflows/pull.yml | 11 +++---- .github/workflows/test-deploy.yml | 4 +-- Makefile | 45 +++++++++++++++++++++++++++ README.md | 6 ++-- package-lock.json | 2 +- 7 files changed, 59 insertions(+), 15 deletions(-) create mode 100644 Makefile diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 51b962e139..e677b1262e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -22,9 +22,9 @@ jobs: cache: npm - name: Install dependencies - run: npm ci + run: make install-dependencies - name: Build website - run: npm run build + run: make build-website # Popular action to deploy to GitHub Pages: # Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus diff --git a/.github/workflows/protect-readmes.yml b/.github/workflows/protect-readmes.yml index f58662d31b..da91b83057 100644 --- a/.github/workflows/protect-readmes.yml +++ b/.github/workflows/protect-readmes.yml @@ -19,4 +19,4 @@ jobs: - name: Check for changes run: | - python3 scripts/protect_readmes.py readme-list + make protect-readmes diff --git a/.github/workflows/pull.yml b/.github/workflows/pull.yml index fbb188a499..e858b8478e 100644 --- a/.github/workflows/pull.yml +++ b/.github/workflows/pull.yml @@ -18,19 +18,19 @@ jobs: git config user.name "${{ secrets.GIT_USERNAME }}" - name: Test pull_readmes script - working-directory: ./osbuild.github.io/scripts + working-directory: ./osbuild.github.io run: | - python3 test_pull_readmes.py + make test - name: Pull readmes and fix links working-directory: ./osbuild.github.io run: | - python3 scripts/pull_readmes.py readme-list + make pull-readmes - name: Pull modules working-directory: ./osbuild.github.io run: | - python3 scripts/pull_osbuild_modules.py + make pull-osbuild-modules - name: Setup node uses: actions/setup-node@v4 @@ -42,8 +42,7 @@ jobs: - name: Test build website working-directory: ./osbuild.github.io run: | - npm ci - npm run build + make build - name: Push updates working-directory: ./osbuild.github.io diff --git a/.github/workflows/test-deploy.yml b/.github/workflows/test-deploy.yml index 27b779c35b..4cead26551 100644 --- a/.github/workflows/test-deploy.yml +++ b/.github/workflows/test-deploy.yml @@ -20,6 +20,6 @@ jobs: cache-dependency-path: package-lock.json - name: Install dependencies - run: yarn install --frozen-lockfile + run: make install-dependencies - name: Test build website - run: yarn build + run: make build-website diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..f91b6760a9 --- /dev/null +++ b/Makefile @@ -0,0 +1,45 @@ + +.PHONY: help +help: + @echo "make [TARGETS...]" + @echo + @echo 'Targets:' + @awk 'match($$0, /^([a-zA-Z_\/-]+):.*?## (.*)$$/, m) {printf " \033[36m%-30s\033[0m %s\n", m[1], m[2]}' $(MAKEFILE_LIST) | sort + +.PHONY: test +.ONESHELL: +test: ## test pulling the readmes from the other projects + pushd scripts + python3 test_pull_readmes.py + popd + +.PHONY: pull-readmes +pull-readmes: ## pull the readmes from other projects given in `readme-list` + python3 scripts/pull_readmes.py readme-list + +.PHONY: pull-osbuild-modules +pull-osbuild-modules: ## pull the documentation of the osbuild modules + python3 scripts/pull_osbuild_modules.py + +.PHONY: generate +generate: pull-readmes pull-osbuild-modules ## generate all external content + +.PHONY: install-dependencies +install-dependencies: ## install all dependencies + npm clean-install + +.PHONY: build-website +build-website: ## build the website (dependencies need to be met) + npm run build + +.PHONY: build +build: install-dependencies build-website ## build the website in one go + +.PHONY: run +run: ## run docusaurus locally for testing + npm start + +.PHONY: protect-readmes +protect-readmes: ## verify the READMEs don't get changed in a pull request (to be used in the workflow) + python3 scripts/protect_readmes.py readme-list + diff --git a/README.md b/README.md index 2b033d6e7d..9df901a4d4 100644 --- a/README.md +++ b/README.md @@ -5,13 +5,13 @@ This website is built using [Docusaurus](https://docusaurus.io/), a modern stati ### Installation ``` -$ npm ci +$ make install-dependencies ``` ### Local Development ``` -$ npm start +$ make run ``` This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server. @@ -19,7 +19,7 @@ This command starts a local development server and opens up a browser window. Mo ### Build ``` -$ npm run build +$ make build ``` This command generates static content into the `build` directory and can be served using any static contents hosting service. diff --git a/package-lock.json b/package-lock.json index 4f5473b795..7929cf3e2d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "dependencies": { "@cmfcmf/docusaurus-search-local": "^1.2.0", "@docusaurus/core": "3.3.2", - "@docusaurus/plugin-client-redirects": "^3.3.2", + "@docusaurus/plugin-client-redirects": "3.3.2", "@docusaurus/preset-classic": "3.3.2", "@mdx-js/react": "^3.0.1", "clsx": "^2.1.1",