bitwarden_workflow_linter 0.8.0__tar.gz → 0.9.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/.github/workflows/bwwl_operations.yml +13 -19
  2. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/.github/workflows/ci.yml +14 -0
  3. bitwarden_workflow_linter-0.9.0/.github/workflows/examples/ci.yaml +52 -0
  4. bitwarden_workflow_linter-0.9.0/.github/workflows/examples/example-references/_build.yml +64 -0
  5. bitwarden_workflow_linter-0.9.0/.github/workflows/examples/example-references/_docker.yml +83 -0
  6. bitwarden_workflow_linter-0.9.0/.github/workflows/examples/example-references/_test.yml +75 -0
  7. bitwarden_workflow_linter-0.9.0/.github/workflows/examples/example-references/_version.yml +68 -0
  8. bitwarden_workflow_linter-0.9.0/.github/workflows/examples/example.yaml +100 -0
  9. bitwarden_workflow_linter-0.9.0/.github/workflows/examples/scan.yaml +126 -0
  10. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/PKG-INFO +21 -16
  11. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/README.md +20 -15
  12. bitwarden_workflow_linter-0.9.0/RULE_ROLLOUT.md +43 -0
  13. bitwarden_workflow_linter-0.9.0/settings.yaml +24 -0
  14. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/src/bitwarden_workflow_linter/__about__.py +1 -1
  15. bitwarden_workflow_linter-0.9.0/src/bitwarden_workflow_linter/default_settings.yaml +24 -0
  16. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/src/bitwarden_workflow_linter/lint.py +23 -4
  17. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/src/bitwarden_workflow_linter/models/workflow.py +2 -0
  18. bitwarden_workflow_linter-0.9.0/src/bitwarden_workflow_linter/rules/permissions_exist.py +43 -0
  19. bitwarden_workflow_linter-0.9.0/tests/rules/test_permissions_exist.py +96 -0
  20. bitwarden_workflow_linter-0.8.0/settings.yaml +0 -21
  21. bitwarden_workflow_linter-0.8.0/src/bitwarden_workflow_linter/default_settings.yaml +0 -21
  22. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/.editorconfig +0 -0
  23. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/.gitattributes +0 -0
  24. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/.github/CODEOWNERS +0 -0
  25. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/.github/ISSUE_TEMPLATE/config.yml +0 -0
  26. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
  27. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/.github/renovate.json +0 -0
  28. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/.github/workflows/_version_type.yml +0 -0
  29. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/.github/workflows/cd.yml +0 -0
  30. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/.github/workflows/enforce-labels.yml +0 -0
  31. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/.github/workflows/scan.yml +0 -0
  32. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/.gitignore +0 -0
  33. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/.husky/pre-commit +0 -0
  34. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/.python-version +0 -0
  35. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/CONTRIBUTING.md +0 -0
  36. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/LICENSE.txt +0 -0
  37. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/Pipfile +0 -0
  38. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/Pipfile.lock +0 -0
  39. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/SECURITY.md +0 -0
  40. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/Taskfile.yml +0 -0
  41. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/package-lock.json +0 -0
  42. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/package.json +0 -0
  43. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/pylintrc +0 -0
  44. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/pyproject.toml +0 -0
  45. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/pyproject.toml.tpl +0 -0
  46. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/src/bitwarden_workflow_linter/__init__.py +0 -0
  47. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/src/bitwarden_workflow_linter/actions.py +0 -0
  48. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/src/bitwarden_workflow_linter/cli.py +0 -0
  49. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/src/bitwarden_workflow_linter/default_actions.json +0 -0
  50. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/src/bitwarden_workflow_linter/load.py +0 -0
  51. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/src/bitwarden_workflow_linter/models/__init__.py +0 -0
  52. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/src/bitwarden_workflow_linter/models/job.py +0 -0
  53. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/src/bitwarden_workflow_linter/models/step.py +0 -0
  54. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/src/bitwarden_workflow_linter/rule.py +0 -0
  55. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/src/bitwarden_workflow_linter/rules/__init__.py +0 -0
  56. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/src/bitwarden_workflow_linter/rules/check_pr_target.py +0 -0
  57. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/src/bitwarden_workflow_linter/rules/job_environment_prefix.py +0 -0
  58. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/src/bitwarden_workflow_linter/rules/name_capitalized.py +0 -0
  59. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/src/bitwarden_workflow_linter/rules/name_exists.py +0 -0
  60. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/src/bitwarden_workflow_linter/rules/pinned_job_runner.py +0 -0
  61. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/src/bitwarden_workflow_linter/rules/run_actionlint.py +0 -0
  62. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/src/bitwarden_workflow_linter/rules/step_approved.py +0 -0
  63. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/src/bitwarden_workflow_linter/rules/step_pinned.py +0 -0
  64. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/src/bitwarden_workflow_linter/rules/underscore_outputs.py +0 -0
  65. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/src/bitwarden_workflow_linter/utils.py +0 -0
  66. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/tests/__init__.py +0 -0
  67. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/tests/conftest.py +0 -0
  68. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/tests/fixtures/test-alt.yml +0 -0
  69. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/tests/fixtures/test-min-incorrect.yaml +0 -0
  70. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/tests/fixtures/test-min.yaml +0 -0
  71. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/tests/fixtures/test-outputs-incorrect.yml +0 -0
  72. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/tests/fixtures/test.yml +0 -0
  73. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/tests/fixtures/test_a.yaml +0 -0
  74. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/tests/fixtures/test_workflow.yaml +0 -0
  75. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/tests/fixtures/test_workflow_incorrect.yaml +0 -0
  76. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/tests/rules/__init__.py +0 -0
  77. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/tests/rules/test_check_pr_target.py +0 -0
  78. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/tests/rules/test_job_environment_prefix.py +0 -0
  79. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/tests/rules/test_name_capitalized.py +0 -0
  80. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/tests/rules/test_name_exists.py +0 -0
  81. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/tests/rules/test_pinned_job_runner.py +0 -0
  82. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/tests/rules/test_run_actionlint.py +0 -0
  83. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/tests/rules/test_step_approved.py +0 -0
  84. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/tests/rules/test_step_pinned.py +0 -0
  85. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/tests/rules/test_underscore_output.py +0 -0
  86. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/tests/test_job.py +0 -0
  87. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/tests/test_lint.py +0 -0
  88. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/tests/test_load.py +0 -0
  89. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/tests/test_rule.py +0 -0
  90. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/tests/test_step.py +0 -0
  91. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/tests/test_utils.py +0 -0
  92. {bitwarden_workflow_linter-0.8.0 → bitwarden_workflow_linter-0.9.0}/tests/test_workflow.py +0 -0
@@ -12,7 +12,7 @@ on:
12
12
  required: false
13
13
  type: string
14
14
  schedule:
15
- - cron: '0 0 1 * *'
15
+ - cron: '0 0 * * 1'
16
16
 
17
17
  jobs:
18
18
  actions-operation:
@@ -63,23 +63,21 @@ jobs:
63
63
  run: python -m pip install --upgrade bitwarden_workflow_linter
64
64
 
65
65
  - name: Create Branch
66
- if: ${{ github.events_name == 'schedule' }} || ${{ inputs.operation == 'update' }}
67
- id: create-branch
66
+ if: ${{ github.events_name == 'schedule' || inputs.operation == 'update' }}
68
67
  run: |
69
68
  NAME="update-actions-$(date +'%Y%m%d-%H%M%S')"
70
69
  git switch -c $NAME
71
- echo "name=$NAME" >> $GITHUB_OUTPUT
70
+ echo "BRANCH_NAME=$NAME" >> $GITHUB_ENV
72
71
 
73
72
  - name: Create Branch
74
73
  if: ${{ inputs.operation == 'add' }}
75
- id: create-branch
76
74
  run: |
77
- NAME= "add-action-$_ACTION"
75
+ NAME="add-action-$_ACTION"
78
76
  git switch -c $NAME
79
- echo "name=$NAME" >> $GITHUB_OUTPUT
77
+ echo "BRANCH_NAME=$NAME" >> $GITHUB_ENV
80
78
 
81
79
  - name: Run bwwl update
82
- if: ${{ github.events_name == 'schedule' }} || ${{ inputs.operation == 'update' }}
80
+ if: ${{ github.events_name == 'schedule' || inputs.operation == 'update' }}
83
81
  run: bwwl actions update -o src/bitwarden_workflow_linter/default_actions.json
84
82
 
85
83
  - name: Run bwwl add
@@ -93,37 +91,33 @@ jobs:
93
91
  echo "new_changes=TRUE" >> $GITHUB_OUTPUT
94
92
  else
95
93
  echo "new_changes=FALSE" >> $GITHUB_OUTPUT
96
- echo "No changes to commit!";
94
+ echo "No changes to commit!"
97
95
  fi
98
96
 
99
97
  - name: Commit changes
100
98
  if: ${{ steps.new-changes.outputs.new_changes == 'TRUE' }}
101
- env:
102
- _PR_BRANCH: ${{ steps.create-branch.outputs.name }}
103
99
  run: |
104
100
  git commit -m "Update approved actions" -a
105
- git push origin "$_PR_BRANCH"
101
+ git push origin "${{ env.BRANCH_NAME }}"
106
102
 
107
103
  - name: Generate GH App token
108
104
  if: ${{ steps.new-changes.outputs.new_changes == 'TRUE' }}
109
105
  uses: actions/create-github-app-token@67e27a7eb7db372a1c61a7f9bdab8699e9ee57f7 # v1.11.3
110
106
  id: app-token
111
107
  with:
112
- app-id: ${{ secrets.GH_APP_ID }}
113
- private-key: ${{ secrets.GH_APP_KEY }}
114
- owner: ${{ github.repository_owner }}
108
+ app-id: ${{ secrets.BW_GHAPP_ID }}
109
+ private-key: ${{ secrets.BW_GHAPP_KEY }}
115
110
 
116
111
  - name: Create PR
117
112
  if: ${{ steps.new-changes.outputs.new_changes == 'TRUE' }}
118
113
  id: create-pr
119
114
  env:
120
115
  GH_TOKEN: ${{ steps.app-token.outputs.token }}
121
- _PR_BRANCH: ${{ steps.create-branch.outputs.name }}
122
- _TITLE: "Update/Add bwwl approved actions"
116
+ TITLE: "Update/Add bwwl approved actions"
123
117
  run: |
124
- PR_URL=$(gh pr create --title "$_TITLE" \
118
+ PR_URL=$(gh pr create --title "$TITLE" \
125
119
  --base "main" \
126
- --head "$_PR_BRANCH" \
120
+ --head "${{ env.BRANCH_NAME }}" \
127
121
  --label "version:patch" \
128
122
  --label "automated pr" \
129
123
  --body "
@@ -7,6 +7,8 @@ on:
7
7
  - "tests/**"
8
8
  workflow_dispatch:
9
9
 
10
+ permissions: read-all
11
+
10
12
  jobs:
11
13
  test:
12
14
  name: CI workflow-linter (v2)
@@ -31,3 +33,15 @@ jobs:
31
33
 
32
34
  - name: Check type hinting
33
35
  run: pipenv run pytype src
36
+
37
+ - name: Test against example workflows
38
+ # run notes:
39
+ # - Changing directories will help catch any repo specific paths in the linter
40
+ # that would not work in a different repository
41
+ # - Changing directories utilizes the default_settings.yaml rather than this repos
42
+ # settings.yaml, which better simulates running from another repository
43
+ # - Using strict to ensure that our examples pass all checks including warnings
44
+ run: |
45
+ pipenv run pip install -e .
46
+ cd .github/workflows
47
+ pipenv run bwwl lint --strict -f ./examples
@@ -0,0 +1,52 @@
1
+ # Workflow templates are based on starter workflows provided by github at
2
+ # https://github.com/actions/starter-workflows/tree/main and customized to
3
+ # represent common practices used on Bitwarden repositories.
4
+
5
+ name: CI
6
+
7
+ on:
8
+ workflow_dispatch: # Allows you to run this workflow manually from the Actions tab
9
+ pull_request: # When a pull request event occurs
10
+
11
+ permissions: # Sets permissions of the GITHUB_TOKEN
12
+ checks: write # Permits an action to create a check run
13
+ contents: read # For actions to fetch code and list commits
14
+ id-token: write # Required to fetch an OpenID Connect (OIDC) token
15
+ pull-requests: write # Permits an action to add a label to a pull request
16
+
17
+ jobs:
18
+ version:
19
+ name: Calculate version
20
+ uses: ./.github/workflows/examples/example-references/_version.yml # Path to an existing github action
21
+
22
+ test:
23
+ name: Run test
24
+ uses: ./.github/workflows/examples/example-references/_test.yml
25
+ with: # Parameters specific to this action that need to be defined in order for the step to be completed
26
+ project-name: Billing.Test
27
+ project-path: ./test/Billing.Test
28
+
29
+ build:
30
+ name: Run build
31
+ needs: # This job will not run until test and version jobs are complete
32
+ - test
33
+ - version
34
+ uses: ./.github/workflows/examples/example-references/_build.yml
35
+ with:
36
+ project-name: Billing
37
+ project-path: ./src/Billing
38
+ version: ${{ needs.version.outputs.version }}
39
+
40
+ build-push-docker:
41
+ name: Build Docker image
42
+ needs:
43
+ - test
44
+ - version
45
+ - build
46
+ uses: ./.github/workflows/examples/example-references/_docker.yml
47
+ with:
48
+ project-name: Billing
49
+ project-path: ./src/Billing
50
+ version: ${{ needs.version.outputs.version }}
51
+ image-name: billing-relay
52
+ push-docker-image: false
@@ -0,0 +1,64 @@
1
+ name: _build
2
+ run-name: Build ${{ inputs.project-name }}
3
+
4
+ on:
5
+ workflow_call:
6
+ inputs:
7
+ project-name:
8
+ type: string
9
+ required: true
10
+ project-path:
11
+ type: string
12
+ required: true
13
+ version:
14
+ type: string
15
+ required: true
16
+
17
+ jobs:
18
+ build:
19
+ name: Build
20
+ runs-on: ubuntu-22.04
21
+ steps:
22
+ - name: Check out repository
23
+ uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
24
+ with:
25
+ fetch-depth: 0
26
+
27
+ - name: Set up .NET
28
+ uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25 # v4.1.0
29
+
30
+ - name: Cache NuGet packages
31
+ uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
32
+ with:
33
+ path: ~/.nuget/packages
34
+ key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
35
+ restore-keys: |
36
+ ${{ runner.os }}-nuget-
37
+
38
+ - name: Install dependencies
39
+ run: dotnet restore ${{ inputs.project-path }}/${{ inputs.project-name }}.csproj
40
+
41
+ - name: Build
42
+ run: dotnet build --verbosity minimal ${{ inputs.project-path }}/${{ inputs.project-name }}.csproj
43
+
44
+ - name: Publish
45
+ run: |
46
+ echo "Publish"
47
+ dotnet publish ${{ inputs.project-path }}/${{ inputs.project-name }}.csproj \
48
+ -c Release --no-restore \
49
+ -o ./tmp/publish-${{ inputs.project-name }} -p:Version=${{ inputs.version }}
50
+
51
+ - name: Create artifact
52
+ run: |
53
+ cd ./tmp/publish-${{ inputs.project-name }}
54
+ zip -r ${{ inputs.project-name }}.zip .
55
+ mv ${{ inputs.project-name }}.zip ../../
56
+ pwd
57
+ ls -atlh ../../
58
+
59
+ - name: Upload artifact
60
+ uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
61
+ with:
62
+ name: ${{ inputs.project-name }}.zip
63
+ path: ./${{ inputs.project-name }}.zip
64
+ if-no-files-found: error
@@ -0,0 +1,83 @@
1
+ name: _docker
2
+ run-name: "Build ${{ inputs.project-name }} docker image and push ${{ inputs.push-docker-image }} to ACR"
3
+
4
+ on:
5
+ workflow_call:
6
+ inputs:
7
+ project-name:
8
+ type: string
9
+ required: true
10
+ project-path:
11
+ type: string
12
+ required: true
13
+ version:
14
+ type: string
15
+ required: false
16
+ push-docker-image:
17
+ type: boolean
18
+ required: false
19
+ default: false
20
+ image-name:
21
+ type: string
22
+ required: true
23
+
24
+ jobs:
25
+ docker:
26
+ name: Docker
27
+ runs-on: ubuntu-22.04
28
+ steps:
29
+ - name: Check out repository
30
+ uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
31
+ with:
32
+ fetch-depth: 0
33
+
34
+ - name: Log in to Azure
35
+ if: ${{ inputs.push-docker-image }}
36
+ uses: Azure/login@a65d910e8af852a8061c627c456678983e180302 # v1.6.1
37
+ with:
38
+ creds: ${{ secrets.AZURE_PROD_KV_CREDENTIALS }}
39
+
40
+ - name: Log in to ACR
41
+ if: ${{ inputs.push-docker-image }}
42
+ run: az acr login -n bitwardenprod
43
+
44
+ - name: Generate Docker image tag
45
+ id: tag
46
+ env:
47
+ VERSION: ${{ inputs.version }}
48
+ run: |
49
+ IMAGE_TAG=$VERSION
50
+ # IMAGE_TAG=$(echo "${GITHUB_REF#refs/heads/}" | sed "s#/#-#g") # slash safe branch name
51
+ # if [[ "$IMAGE_TAG" == "main" ]]; then
52
+ # IMAGE_TAG=$VERSION
53
+ # fi
54
+ echo "image_tag=$IMAGE_TAG" >> $GITHUB_OUTPUT
55
+
56
+ - name: Generate tag list
57
+ id: tag-list
58
+ env:
59
+ IMAGE_TAG: ${{ steps.tag.outputs.image_tag }}
60
+ IMAGE_NAME: ${{ inputs.image-name }}
61
+ run: echo "tags=bitwardenprod.azurecr.io/${IMAGE_NAME}:${IMAGE_TAG}" >> $GITHUB_OUTPUT
62
+
63
+ - name: Get build artifact
64
+ uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
65
+ with:
66
+ name: ${{ inputs.project-name }}.zip
67
+
68
+ - name: Set up build artifact
69
+ run: |
70
+ mkdir -p ${{ inputs.project-path }}/obj/build-output/publish
71
+ unzip ${{ inputs.project-name }}.zip \
72
+ -d ${{ inputs.project-path }}/obj/build-output/publish
73
+
74
+ - name: Build Docker image
75
+ uses: docker/build-push-action@48aba3b46d1b1fec4febb7c5d0c644b249a11355 # v6.10.0
76
+ with:
77
+ context: ${{ inputs.project-path }}
78
+ file: ${{ inputs.project-path }}/Dockerfile
79
+ platforms: linux/amd64
80
+ push: ${{ inputs.push-docker-image }}
81
+ tags: ${{ steps.tag-list.outputs.tags }}
82
+ env:
83
+ DOCKER_BUILD_RECORD_UPLOAD: false
@@ -0,0 +1,75 @@
1
+ name: _test
2
+ run-name: Test ${{ inputs.project-name }}
3
+
4
+ on:
5
+ workflow_call:
6
+ inputs:
7
+ project-name:
8
+ type: string
9
+ required: true
10
+ project-path:
11
+ type: string
12
+ required: true
13
+
14
+ jobs:
15
+ check-test-secrets:
16
+ name: Check for test secrets
17
+ runs-on: ubuntu-22.04
18
+ outputs:
19
+ available: ${{ steps.check-test-secrets.outputs.available }}
20
+ permissions:
21
+ contents: read
22
+
23
+ steps:
24
+ - name: Check
25
+ id: check-test-secrets
26
+ run: |
27
+ if [ "${{ secrets.CODECOV_TOKEN }}" != '' ]; then
28
+ echo "available=true" >> $GITHUB_OUTPUT;
29
+ else
30
+ echo "available=false" >> $GITHUB_OUTPUT;
31
+ fi
32
+
33
+ testing:
34
+ name: Test
35
+ runs-on: ubuntu-22.04
36
+ needs: check-test-secrets
37
+ permissions:
38
+ checks: write
39
+ contents: read
40
+ pull-requests: write
41
+
42
+ steps:
43
+ - name: Check out repo
44
+ uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
45
+ with:
46
+ fetch-depth: 0
47
+
48
+ - name: Set up .NET
49
+ uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25 # v4.1.0
50
+
51
+ - name: Cache NuGet packages
52
+ uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
53
+ with:
54
+ path: ~/.nuget/packages
55
+ key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
56
+ restore-keys: |
57
+ ${{ runner.os }}-nuget-
58
+
59
+ - name: Install dependencies
60
+ run: dotnet restore --locked-mode ${{ inputs.project-path }}/${{ inputs.project-name }}.csproj
61
+
62
+ - name: Build
63
+ run: dotnet build --verbosity minimal ${{ inputs.project-path }}/${{ inputs.project-name }}.csproj
64
+
65
+ - name: Test
66
+ run: dotnet test ${{ inputs.project-path }}/${{ inputs.project-name }}.csproj --no-build --logger "trx;LogFileName=mothership-test-results.trx"
67
+
68
+ - name: Report test results
69
+ uses: dorny/test-reporter@31a54ee7ebcacc03a09ea97a7e5465a47b84aea5 # v1.9.1
70
+ if: ${{ needs.check-test-secrets.outputs.available == 'true' && !cancelled() }}
71
+ with:
72
+ name: Test Results
73
+ path: "**/*-test-results.trx"
74
+ reporter: dotnet-trx
75
+ fail-on-error: true
@@ -0,0 +1,68 @@
1
+ name: _version
2
+ run-name: Calculate version
3
+
4
+ on:
5
+ workflow_call:
6
+ inputs:
7
+ is-release:
8
+ type: boolean
9
+ default: false
10
+ outputs:
11
+ version:
12
+ description: "version to be built"
13
+ value: ${{ jobs.version.outputs.version }}
14
+
15
+ jobs:
16
+ version:
17
+ name: Calculate version
18
+ runs-on: ubuntu-22.04
19
+ outputs:
20
+ version: ${{ steps.version.outputs.value }}
21
+ steps:
22
+ - name: Check out repository
23
+ uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
24
+ with:
25
+ fetch-depth: 0
26
+
27
+ - name: Generate version
28
+ id: version
29
+ run: |
30
+ ls -la
31
+ git fetch --prune --tags
32
+
33
+ echo "Calculating next version..."
34
+
35
+ base_version=$(cat Directory.build.props |
36
+ grep -o "<BaseVersion>.*</BaseVersion>" |
37
+ grep -Eo "[0-9]+\.[0-9]+"
38
+ )
39
+ major_version=$(echo $base_version | grep -Eo "[0-9]+" | head -1)
40
+ minor_version=$(echo $base_version | grep -Eo "[0-9]+" | sed -n 2p)
41
+
42
+ latest_tag_version=$(git tag --sort=committerdate --list | tail -1)
43
+ echo " latest_tag_version: $latest_tag_version"
44
+
45
+ major_latest_tag_version=$(echo $latest_tag_version | grep -Eo "[0-9]+" | head -1)
46
+ echo " major_latest_tag_version: $major_latest_tag_version"
47
+
48
+ minor_latest_tag_version=$(echo $latest_tag_version | grep -Eo "[0-9]+" | sed -n 2p)
49
+ echo " minor_latest_tag_version: $minor_latest_tag_version"
50
+
51
+ if [[ "$major_latest_tag_version" != "$major_version" ]] || \
52
+ [[ "$minor_latest_tag_version" != "$minor_version" ]]; then
53
+ patch_version="0"
54
+ else
55
+ patch_version=$((${latest_tag_version##*.} + 1))
56
+ fi
57
+
58
+ echo " patch_version: $patch_version"
59
+
60
+ version_suffix=$patch_version
61
+
62
+ if [[ "${{ inputs.is-release }}" == "false" ]]; then
63
+ version_suffix=$version_suffix-${GITHUB_SHA:0:7}
64
+ fi
65
+
66
+ echo " version: $base_version.$version_suffix"
67
+ echo "value=$base_version.$version_suffix" >> $GITHUB_OUTPUT
68
+ echo "Done"
@@ -0,0 +1,100 @@
1
+ # Workflow templates are based on starter workflows provided by github at
2
+ # https://github.com/actions/starter-workflows/tree/main and customized to
3
+ # represent common practices used on ACME repositories.
4
+
5
+ # This imaginary workflow runs two steps and illustrates a number of options that we use throughout workflows in the Bitwarden repositories
6
+
7
+ name: Build
8
+
9
+ on: # Describes when to run the workflow
10
+ # https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows
11
+
12
+ workflow_dispatch: # When triggered manually
13
+
14
+ push: # On push to the following branches. Temporarily add a development branch to prompt workflow runs for troubleshooting
15
+ branches: ["main", "rc", "hotfix-rc"]
16
+ paths-ignore: # Updates to these directories or files will not trigger a workflow run
17
+ - ".github/workflows/**"
18
+
19
+ # Pull_request_target: #We strongly discourage using this unless absolutely necessary as it requires access to certain Github secrets.
20
+ # If using this, include the .github/workflows/check-run.yml job and target only the main branch
21
+ # More info at https://github.blog/news-insights/product-news/github-actions-improvements-for-fork-and-pull-request-workflows/#improvements-for-public-repository-forks
22
+
23
+ pull_request: # When a pull request event occurs
24
+ types: [opened, synchronize, unlabeled, labeled, unlabeled, reopened, edited]
25
+ branches: ["main"] # Branches where a pull request will trigger the workflow
26
+
27
+
28
+ release: # Runs your workflow when release activity in your repository occurs
29
+ types: [published, created]
30
+
31
+ merge_group: # Runs required status checks on merge groups created by merge queue
32
+ types: [checks_requested]
33
+
34
+ repository_dispatch: # Runs when a webook event triggers a workflow from outside of github
35
+ types: [contentful-publish] # Optional, limit repository dispatch events to those in a specified list
36
+
37
+ workflow_call: # Workflow can be called by another workflow
38
+
39
+ env: # Environment variables set for this step but not accessible by all workflows, steps or jobs.
40
+ _AZ_REGISTRY: "ACMEprod.azurecr.io"
41
+ INCREMENTAL: "${{ contains(github.event_name, 'pull_request') && '--sast-incremental' || '' }}"
42
+
43
+ jobs: # A workflow run is made up of one or more jobs that can run sequentially or in parallel
44
+ first-job:
45
+ name: First Job Name
46
+ uses: ./.github/workflows/examples/example-references/_version.yml # Path to an existing github action
47
+ if: github.event.pull_request.draft == false # prevent part of a job from running on a draft PR
48
+ secrets: inherit # When called by another workflow, pass all the calling workflow's secrets to the called workflow
49
+ # "secrets" is only available for a reusable workflow call with "uses"
50
+ strategy: # Create multiple job runs for each of a set of variables
51
+ fail-fast: false # If true, cancel entire run if any job in the matrix fails
52
+ matrix: # Matrix of variables used to define multiple job runs
53
+ include:
54
+ - project_name: Admin
55
+ base_path: ./src
56
+ node: true # Enables steps with if: ${{ matrix.node }}
57
+
58
+ # https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/controlling-permissions-for-github_token
59
+ permissions: # Sets permissions of the GITHUB_TOKEN
60
+ security-events: write # Allow actions to upload results to Github
61
+ id-token: write # Required to fetch an OpenID Connect (OIDC) token
62
+ contents: read # For actions/checkout to fetch code
63
+ deployments: write # Permits an action to create a new deployment
64
+ issues: write # Permits an action to create a new issue
65
+ checks: write # Permits an action to create a check run
66
+ actions: write # Permits an action to cancel a workflow run
67
+ packages: read # Permits an action to access packages on GitHub Packages
68
+ pull-requests: write # Permits an action to add a label to a pull request
69
+
70
+ # steps: when a reusable workflow is called with "uses", "steps" is not available
71
+ second-job:
72
+ name: Second Job Name
73
+ runs-on: ubuntu-22.04 # The type of runner that the job will run on, not available if "uses" is used
74
+ defaults:
75
+ run: # Set the default shell and working directory
76
+ shell: bash
77
+ working-directory: "home/WorkingDirectory"
78
+
79
+ needs:
80
+ - first-job # This job will wait until first-job completes
81
+ # https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/setting-a-default-shell-and-working-directory
82
+ steps:
83
+ - name: Descriptive step name
84
+ # NOT RECOMMENDED if: always() # run even if previous steps failed or the workflow is canceled, this can cause a workflow run to hang indefinitely
85
+ if: failure() # run when any previous step of a job fails
86
+ # if: '!cancelled()' # run even if previous steps failed
87
+ uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 Always pin a public action version to a full git SHA, followed by the version number in a comment. Version pins are insecure and can introduce vulnerabilities into workflows.
88
+ with: # Parameters specific to this action that need to be defined in order for the step to be completed
89
+ fetch-depth: 0 # Full git history for actions that rely on whether a change has occurred
90
+ ref: ${{ github.event.pull_request.head.sha }}
91
+ creds: ${{ secrets.SECRETS_OR_CREDENTIALS }}
92
+ - name: Another descriptive step name
93
+ # Run a script instead of an existing github action
94
+ run: |
95
+ whoami
96
+ dotnet --info
97
+ node --version
98
+ npm --version
99
+ echo "GitHub ref: $GITHUB_REF"
100
+ echo "GitHub event: $GITHUB_EVENT"
@@ -0,0 +1,126 @@
1
+ # Workflow templates are based on starter workflows provided by github at
2
+ # https://github.com/actions/starter-workflows/tree/main and customized to
3
+ # represent common practices used on Bitwarden repositories.
4
+
5
+ # The Scan Workflow enables you to trigger SAST and quality scans directly
6
+ # From the GitHub workflow.
7
+
8
+ name: Scan
9
+
10
+ on:
11
+ # Controls when the workflow will run
12
+
13
+ # Can use other triggers such as multiple events, activity types and fiters:
14
+ # https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#on
15
+ workflow_dispatch: # When triggered manually
16
+
17
+ push:
18
+ # On push to the following branches. Temporarily add a development
19
+ # branch to prompt workflow runs for troubleshooting
20
+ branches:
21
+ - "main"
22
+ - "rc"
23
+ - "hotfix-rc"
24
+ pull_request_target:
25
+ # When a pull request event occurs. Default is opened or reopened unless
26
+ # otherwise specified, as below:
27
+ types: [opened, synchronize] # Options include labeled, unlabeled, reopened
28
+ branches: 'main'
29
+
30
+ # A workflow run is made up of one or more jobs that can run sequentially or in
31
+ # parallel
32
+ jobs:
33
+ # This workflow contains the jobs "check-run", "sast", and "quality"
34
+ # This job is relatively simple and just imports a previously written action
35
+ # to be used in this workflow
36
+ check-run: # You set this value with the name of the job you're describing
37
+ name: Check PR run # Human readable descriptor
38
+ # location and branch of bitwarden-owned action being used
39
+ uses: bitwarden/gh-actions/.github/workflows/check-run.yml@main
40
+
41
+ sast:
42
+ # A more complex job that has multiple actions as steps described below
43
+ name: SAST scan
44
+ runs-on: ubuntu-22.04 # The type of runner that the job will run on
45
+ needs: check-run # This job will wait until check-run completes
46
+ permissions: # Sets permissions of the GITHUB_TOKEN
47
+ contents: read # For actions/checkout to fetch code
48
+ pull-requests: write # For github actions to upload feedback to PR
49
+ # For github/codeql-action/upload-sarif to upload SARIF results
50
+ security-events: write
51
+
52
+ # Steps represent a sequence of tasks executed as part of the job
53
+ steps:
54
+ - name: Check out repo
55
+ # Always pin a public action version to a full git SHA.
56
+ # Version pins are insecure and can introduce vulnerabilities
57
+ # into workflows.
58
+ uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
59
+ with:
60
+ # Parameters specific to this action that need to be defined
61
+ # in order for the step to be completed
62
+ ref: ${{ github.event.pull_request.head.sha }}
63
+
64
+ - name: Scan with Checkmarx
65
+ if: github.event.pull_request.draft == false # Prevent step from running on draft PR
66
+ uses: checkmarx/ast-github-action@f0869bd1a37fddc06499a096101e6c900e815d81 # 2.0.36
67
+ # Environment variables set for this step but not accessible by all
68
+ # workflows, steps or jobs
69
+ env:
70
+ INCREMENTAL: "${{ contains(github.event_name, 'pull_request') \
71
+ && '--sast-incremental' || '' }}"
72
+ with:
73
+ project_name: ${{ github.repository }}
74
+ cx_tenant: ${{ secrets.CHECKMARX_TENANT }}
75
+ base_uri: https://ast.checkmarx.net/
76
+ cx_client_id: ${{ secrets.CHECKMARX_CLIENT_ID }}
77
+ cx_client_secret: ${{ secrets.CHECKMARX_SECRET }}
78
+ additional_params: |
79
+ --report-format sarif \
80
+ --filter \
81
+ "state=TO_VERIFY;PROPOSED_NOT_EXPLOITABLE;CONFIRMED;URGENT"\
82
+ --output-path . ${{ env.INCREMENTAL }}
83
+
84
+ - name: Upload Checkmarx results to GitHub
85
+ uses: github/codeql-action/upload-sarif@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0
86
+ with:
87
+ sarif_file: cx_result.sarif
88
+
89
+ quality:
90
+ name: Quality scan
91
+ runs-on: ubuntu-22.04
92
+ needs: check-run
93
+ permissions:
94
+ contents: read
95
+ pull-requests: write
96
+
97
+ steps:
98
+ # Set up whatever resources your environment will need
99
+ # to run workflows on your code
100
+ - name: Set up JDK 17
101
+ uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0
102
+ with:
103
+ java-version: 17
104
+ distribution: "zulu"
105
+ # This step checks out a copy of your repository
106
+ - name: Set up .NET
107
+ uses: actions/setup-dotnet@3e891b0cb619bf60e2c25674b222b8940e2c1c25 # v4.1.0
108
+ # Install a tool without a Github Action
109
+ - name: Install SonarCloud scanner
110
+ run: dotnet tool install dotnet-sonarscanner -g
111
+
112
+ - name: Scan with SonarCloud
113
+ env:
114
+ SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
115
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
116
+ # Additional scripts to run outside of a Github Action
117
+ run: |
118
+ dotnet-sonarscanner begin /k:" \
119
+ ${{ github.repository_owner }}_${{ github.event.repository.name }}" \
120
+ /d:sonar.test.inclusions=test/,bitwarden_license/test/ \
121
+ /d:sonar.exclusions=test/,bitwarden_license/test/ \
122
+ /o:"${{ github.repository_owner }}" \
123
+ /d:sonar.token="${{ secrets.SONAR_TOKEN }}" \
124
+ /d:sonar.host.url="https://sonarcloud.io"
125
+ dotnet build
126
+ dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"