Skip to content

Commit

Permalink
ci: enable yarn hardened mode only once for the workflow (#2133)
Browse files Browse the repository at this point in the history
## Proposed change

Since Yarn 4, hardened mode is enable by default on GitHub public pull
requests.
This can considerably slow down the yarn install
See https://yarnpkg.com/features/security#hardened-mode

As recommended, we just need to run it once

## Related issues

- 🐛 Fixes #(issue)
- 🚀 Feature #(issue)

<!-- Please make sure to follow the contributing guidelines on
https://github.com/amadeus-digital/Otter/blob/main/CONTRIBUTING.md -->
  • Loading branch information
fpaul-1A committed Sep 5, 2024
2 parents ce8ef71 + afc62eb commit 07f774e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/workflows/code-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ on:

env:
NX_SKIP_NX_CACHE: ${{ inputs.skipNxCache }}
YARN_ENABLE_HARDENED_MODE: 0

permissions:
contents: read
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on:

env:
NX_SKIP_NX_CACHE: ${{ inputs.skipNxCache }}
YARN_ENABLE_HARDENED_MODE: 0

permissions:
contents: read
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/it-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on:

env:
NX_SKIP_NX_CACHE: ${{ inputs.skipNxCache }}
YARN_ENABLE_HARDENED_MODE: 0

permissions:
contents: read
Expand Down
25 changes: 20 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,22 @@ on:
merge_group:
types: [checks_requested]

env:
YARN_ENABLE_HARDENED_MODE: 0

jobs:
# Check the integrity of yarn lock
yarn_lock_check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: ./tools/github-actions/setup
env:
YARN_ENABLE_HARDENED_MODE: 1

build:
runs-on: ubuntu-latest
needs: [yarn_lock_check]
env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
NX_SKIP_NX_CACHE: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release') }}
Expand All @@ -40,6 +53,7 @@ jobs:
# Needed to publish release on GitHub
contents: write
runs-on: ubuntu-latest
needs: [yarn_lock_check]
outputs:
nextVersionTag: ${{ steps.newVersion.outputs.nextVersionTag }}
isPreRelease: ${{ contains( steps.newVersion.outputs.nextVersionTag, '-' ) || github.event_name == 'pull_request' || github.event_name == 'merge_group'}}
Expand All @@ -64,6 +78,7 @@ jobs:
uses: ./.github/workflows/code-check.yml
secrets:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
needs: [yarn_lock_check]
with:
affected: ${{ github.event_name == 'pull_request' }}
skipNxCache: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release') }}
Expand All @@ -72,15 +87,15 @@ jobs:
uses: ./.github/workflows/it-tests.yml
secrets:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
needs: [build]
needs: [yarn_lock_check, build]
with:
skipNxCache: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release') }}

e2e-tests:
uses: ./.github/workflows/e2e-tests.yml
secrets:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
needs: [build]
needs: [yarn_lock_check, build]
with:
skipNxCache: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release') }}

Expand All @@ -92,7 +107,7 @@ jobs:
# Needed to publish with provenance
id-token: write
secrets: inherit
needs: [version, build, checks, it-tests]
needs: [yarn_lock_check, version, build, checks, it-tests]
with:
version: ${{ needs.version.outputs.nextVersionTag }}
prerelease: ${{ needs.version.outputs.isPreRelease == 'true' }}
Expand All @@ -101,14 +116,14 @@ jobs:

documentation-main:
secrets: inherit
needs: [version, build, checks]
needs: [yarn_lock_check, version, build, checks]
if: ${{ github.event_name != 'pull_request' && github.event_name != 'merge_group' && github.ref_name == 'main' }}
uses: ./.github/workflows/documentation.yml
with:
version: ${{ needs.version.outputs.nextVersionTag }}
documentation-pr:
secrets: inherit
needs: [version]
needs: [yarn_lock_check, version]
if: ${{ (github.event_name == 'pull_request' && github.base_ref == 'main') || github.event_name == 'merge_group' }}
uses: ./.github/workflows/documentation.yml
with:
Expand Down

0 comments on commit 07f774e

Please sign in to comment.