From 04a5d36eb6ca95c18073586359e4e44365fc88df Mon Sep 17 00:00:00 2001 From: Jakob Krigovsky Date: Sat, 2 May 2020 20:09:11 +0200 Subject: [PATCH] Use Prettier for Markdown As Prettier infers the parser from the input file path, the `parser` option can be safely removed. --- .prettierrc.json | 9 ++++++++- CODE_OF_CONDUCT.md | 20 ++++++++++---------- CONTRIBUTING.md | 2 +- README.md | 38 +++++++++++++++++++++----------------- examples.md | 36 +++++++++++++++++++++++++----------- package.json | 4 ++-- 6 files changed, 67 insertions(+), 42 deletions(-) diff --git a/.prettierrc.json b/.prettierrc.json index eec6f1c..0342675 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -7,5 +7,12 @@ "trailingComma": "none", "bracketSpacing": true, "arrowParens": "avoid", - "parser": "typescript" + "overrides": [ + { + "files": "**/*.md", + "options": { + "tabWidth": 2 + } + } + ] } \ No newline at end of file diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index a0047d8..964fb4b 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -14,21 +14,21 @@ appearance, race, religion, or sexual identity and orientation. Examples of behavior that contributes to creating a positive environment include: -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members +- Using welcoming and inclusive language +- Being respectful of differing viewpoints and experiences +- Gracefully accepting constructive criticism +- Focusing on what is best for the community +- Showing empathy towards other community members Examples of unacceptable behavior by participants include: -* The use of sexualized language or imagery and unwelcome sexual attention or +- The use of sexualized language or imagery and unwelcome sexual attention or advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic +- Trolling, insulting/derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or electronic address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a +- Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e11bb5a..687268d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -31,4 +31,4 @@ Here are a few things you can do that will increase the likelihood of your pull - [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/) - [Using Pull Requests](https://help.github.com/articles/about-pull-requests/) -- [GitHub Help](https://help.github.com) \ No newline at end of file +- [GitHub Help](https://help.github.com) diff --git a/README.md b/README.md index a979c38..55eddee 100644 --- a/README.md +++ b/README.md @@ -11,17 +11,18 @@ See ["Caching dependencies to speed up workflows"](https://help.github.com/githu ## Usage ### Pre-requisites + Create a workflow `.yml` file in your repositories `.github/workflows` directory. An [example workflow](#example-workflow) is available below. For more information, reference the GitHub Help Documentation for [Creating a workflow file](https://help.github.com/en/articles/configuring-a-workflow#creating-a-workflow-file). ### Inputs -* `path` - A directory to store and save the cache -* `key` - An explicit key for restoring and saving the cache -* `restore-keys` - An ordered list of keys to use for restoring the cache if no cache hit occurred for key +- `path` - A directory to store and save the cache +- `key` - An explicit key for restoring and saving the cache +- `restore-keys` - An ordered list of keys to use for restoring the cache if no cache hit occurred for key ### Outputs -* `cache-hit` - A boolean value to indicate an exact match was found for the key +- `cache-hit` - A boolean value to indicate an exact match was found for the key > See [Skipping steps based on cache-hit](#Skipping-steps-based-on-cache-hit) for info on using this output @@ -37,21 +38,21 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v2 - - name: Cache Primes - id: cache-primes - uses: actions/cache@v1 - with: - path: prime-numbers - key: ${{ runner.os }}-primes + - name: Cache Primes + id: cache-primes + uses: actions/cache@v1 + with: + path: prime-numbers + key: ${{ runner.os }}-primes - - name: Generate Prime Numbers - if: steps.cache-primes.outputs.cache-hit != 'true' - run: /generate-primes.sh -d prime-numbers + - name: Generate Prime Numbers + if: steps.cache-primes.outputs.cache-hit != 'true' + run: /generate-primes.sh -d prime-numbers - - name: Use Prime Numbers - run: /primes.sh -d prime-numbers + - name: Use Prime Numbers + run: /primes.sh -d prime-numbers ``` ## Implementation Examples @@ -82,13 +83,14 @@ See [Examples](examples.md) for a list of `actions/cache` implementations for us ## Cache Limits -A repository can have up to 5GB of caches. Once the 5GB limit is reached, older caches will be evicted based on when the cache was last accessed. Caches that are not accessed within the last week will also be evicted. +A repository can have up to 5GB of caches. Once the 5GB limit is reached, older caches will be evicted based on when the cache was last accessed. Caches that are not accessed within the last week will also be evicted. ## Skipping steps based on cache-hit Using the `cache-hit` output, subsequent steps (such as install or build) can be skipped when a cache hit occurs on the key. Example: + ```yaml steps: - uses: actions/checkout@v2 @@ -107,7 +109,9 @@ steps: > Note: The `id` defined in `actions/cache` must match the `id` in the `if` statement (i.e. `steps.[ID].outputs.cache-hit`) ## Contributing + We would love for you to contribute to `@actions/cache`, pull requests are welcome! Please see the [CONTRIBUTING.md](CONTRIBUTING.md) for more information. ## License + The scripts and documentation in this project are released under the [MIT License](LICENSE) diff --git a/examples.md b/examples.md index e9f43cc..3316522 100644 --- a/examples.md +++ b/examples.md @@ -31,6 +31,7 @@ - [Swift - Swift Package Manager](#swift---swift-package-manager) ## C# - NuGet + Using [NuGet lock files](https://docs.microsoft.com/nuget/consume-packages/package-references-in-project-files#locking-dependencies): ```yaml @@ -44,7 +45,9 @@ Using [NuGet lock files](https://docs.microsoft.com/nuget/consume-packages/packa Depending on the environment, huge packages might be pre-installed in the global cache folder. If you do not want to include them, consider to move the cache folder like below. ->Note: This workflow does not work for projects that require files to be placed in user profile package folder + +> Note: This workflow does not work for projects that require files to be placed in user profile package folder + ```yaml env: NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages @@ -58,6 +61,7 @@ steps: ``` ## Elixir - Mix + ```yaml - uses: actions/cache@v1 with: @@ -126,7 +130,7 @@ We cache the elements of the Cabal store separately, as the entirety of `~/.caba For npm, cache files are stored in `~/.npm` on Posix, or `%AppData%/npm-cache` on Windows. See https://docs.npmjs.com/cli/cache#cache ->Note: It is not recommended to cache `node_modules`, as it can break across Node versions and won't work with `npm ci` +> Note: It is not recommended to cache `node_modules`, as it can break across Node versions and won't work with `npm ci` ### macOS and Ubuntu @@ -171,7 +175,8 @@ For npm, cache files are stored in `~/.npm` on Posix, or `%AppData%/npm-cache` o ## Node - Lerna ->Note this example uses the new multi-paths feature and is only available at `master` +> Note this example uses the new multi-paths feature and is only available at `master` + ```yaml - name: restore lerna uses: actions/cache@master @@ -183,6 +188,7 @@ For npm, cache files are stored in `~/.npm` on Posix, or `%AppData%/npm-cache` o ``` ## Node - Yarn + The yarn cache directory will depend on your operating system and version of `yarn`. See https://yarnpkg.com/lang/en/docs/cli/cache/ for more info. ```yaml @@ -200,7 +206,9 @@ The yarn cache directory will depend on your operating system and version of `ya ``` ## OCaml/Reason - esy + Esy allows you to export built dependencies and import pre-built dependencies. + ```yaml - name: Restore Cache id: restore-cache @@ -220,13 +228,12 @@ Esy allows you to export built dependencies and import pre-built dependencies. ...(Build job)... # Re-export dependencies if anything has changed or if it is the first time - - name: Setting dependency cache + - name: Setting dependency cache run: | esy export-dependencies if: steps.restore-cache.outputs.cache-hit != 'true' ``` - ## PHP - Composer ```yaml @@ -247,11 +254,13 @@ Esy allows you to export built dependencies and import pre-built dependencies. For pip, the cache directory will vary by OS. See https://pip.pypa.io/en/stable/reference/pip_install/#caching Locations: - - Ubuntu: `~/.cache/pip` - - Windows: `~\AppData\Local\pip\Cache` - - macOS: `~/Library/Caches/pip` + +- Ubuntu: `~/.cache/pip` +- Windows: `~\AppData\Local\pip\Cache` +- macOS: `~/Library/Caches/pip` ### Simple example + ```yaml - uses: actions/cache@v1 with: @@ -294,6 +303,7 @@ Replace `~/.cache/pip` with the correct `path` if not using Ubuntu. ### Using pip to get cache location > Note: This requires pip 20.1+ + ```yaml - name: Get pip cache dir id: pip-cache @@ -312,6 +322,7 @@ Replace `~/.cache/pip` with the correct `path` if not using Ubuntu. ### Using a script to get cache location > Note: This uses an internal pip API and may not always work + ```yaml - name: Get pip cache dir id: pip-cache @@ -331,11 +342,13 @@ Replace `~/.cache/pip` with the correct `path` if not using Ubuntu. For renv, the cache directory will vary by OS. Look at https://rstudio.github.io/renv/articles/renv.html#cache Locations: - - Ubuntu: `~/.local/share/renv` - - macOS: `~/Library/Application Support/renv` - - Windows: `%LOCALAPPDATA%/renv` + +- Ubuntu: `~/.local/share/renv` +- macOS: `~/Library/Application Support/renv` +- Windows: `%LOCALAPPDATA%/renv` ### Simple example + ```yaml - uses: actions/cache@v1 with: @@ -385,6 +398,7 @@ Replace `~/.local/share/renv` with the correct `path` if not using Ubuntu. restore-keys: | ${{ runner.os }}-gems- ``` + When dependencies are installed later in the workflow, we must specify the same path for the bundler. ```yaml diff --git a/package.json b/package.json index b50db38..b9a3e3b 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,8 @@ "build": "tsc && ncc build -o dist/restore src/restore.ts && ncc build -o dist/save src/save.ts", "test": "tsc --noEmit && jest --coverage", "lint": "eslint **/*.ts --cache", - "format": "prettier --write **/*.ts", - "format-check": "prettier --check **/*.ts" + "format": "prettier --write **/*.{md,ts}", + "format-check": "prettier --check **/*.{md,ts}" }, "repository": { "type": "git",