rails_template_18f 1.3.0 → 2.1.0

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 (88) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -0
  3. data/Gemfile +1 -1
  4. data/Gemfile.lock +64 -61
  5. data/README.md +11 -16
  6. data/lib/generators/rails_template18f/active_storage/active_storage_generator.rb +7 -6
  7. data/lib/generators/rails_template18f/circleci/circleci_generator.rb +28 -27
  8. data/lib/generators/rails_template18f/circleci/templates/Dockerfile.ci.tt +0 -1
  9. data/lib/generators/rails_template18f/circleci/templates/circleci/config.yml.tt +162 -163
  10. data/lib/generators/rails_template18f/cloud_gov_config/templates/app/models/cloud_gov_config.rb +9 -1
  11. data/lib/generators/rails_template18f/github_actions/github_actions_generator.rb +31 -30
  12. data/lib/generators/rails_template18f/github_actions/templates/github/actions/compile-assets/action.yml +50 -0
  13. data/lib/generators/rails_template18f/github_actions/templates/github/actions/setup-project/action.yml.tt +4 -8
  14. data/lib/generators/rails_template18f/github_actions/templates/github/dependabot.yml.tt +2 -4
  15. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/deploy-production.yml +74 -0
  16. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/deploy-staging.yml +74 -0
  17. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/owasp-daily-scan.yml.tt +10 -1
  18. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/owasp-scan.yml.tt +1 -1
  19. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/pa11y.yml.tt +2 -2
  20. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/terraform-production.yml +49 -4
  21. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/terraform-staging.yml +49 -4
  22. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/validate-ssp.yml +2 -2
  23. data/lib/generators/rails_template18f/gitlab_ci/gitlab_ci_generator.rb +147 -0
  24. data/lib/generators/rails_template18f/gitlab_ci/templates/gitlab/node.yml.tt +11 -0
  25. data/lib/generators/rails_template18f/gitlab_ci/templates/gitlab/rails.yml +75 -0
  26. data/lib/generators/rails_template18f/gitlab_ci/templates/gitlab/ruby.yml +7 -0
  27. data/lib/generators/rails_template18f/gitlab_ci/templates/gitlab/terraform.yml +28 -0
  28. data/lib/generators/rails_template18f/gitlab_ci/templates/gitlab-ci.yml.tt +212 -0
  29. data/lib/generators/rails_template18f/i18n_js/i18n_js_generator.rb +2 -2
  30. data/lib/generators/rails_template18f/i18n_js/templates/app/javascript/{i18n.js → i18n/index.js} +1 -1
  31. data/lib/generators/rails_template18f/i18n_js/templates/config/i18n-js.yml +1 -1
  32. data/lib/generators/rails_template18f/newrelic/newrelic_generator.rb +4 -2
  33. data/lib/generators/rails_template18f/public_egress/public_egress_generator.rb +71 -55
  34. data/lib/generators/rails_template18f/sidekiq/sidekiq_generator.rb +8 -17
  35. data/lib/generators/rails_template18f/terraform/templates/full_bootstrap/imports.tf.tftpl +25 -0
  36. data/lib/generators/rails_template18f/terraform/templates/full_bootstrap/main.tf.tt +159 -0
  37. data/lib/generators/rails_template18f/terraform/templates/sandbox_bootstrap/imports.tf.tftpl +10 -0
  38. data/lib/generators/rails_template18f/terraform/templates/sandbox_bootstrap/main.tf.tt +117 -0
  39. data/lib/generators/rails_template18f/terraform/templates/terraform/README.md.tt +69 -95
  40. data/lib/generators/rails_template18f/terraform/templates/terraform/app.tf.tt +57 -0
  41. data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/apply.sh +15 -0
  42. data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/templates/backend_config.tftpl +8 -0
  43. data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/templates/bot_secrets.tftpl +5 -0
  44. data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/users.auto.tfvars +5 -0
  45. data/lib/generators/rails_template18f/terraform/templates/terraform/main.tf.tt +117 -0
  46. data/lib/generators/rails_template18f/terraform/templates/terraform/production.tfvars.tt +13 -0
  47. data/lib/generators/rails_template18f/terraform/templates/terraform/providers.tf.tt +18 -0
  48. data/lib/generators/rails_template18f/terraform/templates/terraform/staging.tfvars.tt +8 -0
  49. data/lib/generators/rails_template18f/terraform/templates/terraform/terraform.sh.tt +95 -0
  50. data/lib/generators/rails_template18f/terraform/templates/terraform/variables.tf.tt +98 -0
  51. data/lib/generators/rails_template18f/terraform/terraform_generator.rb +12 -4
  52. data/lib/rails_template18f/generators/cloud_gov_options.rb +9 -6
  53. data/lib/rails_template18f/generators/cloud_gov_parsing.rb +7 -7
  54. data/lib/rails_template18f/generators.rb +0 -1
  55. data/lib/rails_template18f/version.rb +1 -1
  56. data/rails-template-18f.gemspec +4 -4
  57. data/railsrc +4 -2
  58. data/railsrc-hotwire +4 -2
  59. data/template.rb +80 -82
  60. data/templates/README.md.tt +21 -8
  61. data/templates/app/assets/stylesheets/uswds-settings.scss +3 -2
  62. data/templates/app/views/application/_header.html.erb +1 -1
  63. data/templates/app/views/application/_usa_banner.html.erb +3 -3
  64. data/templates/bin/ops/create_service_account.sh.tt +20 -11
  65. data/templates/bin/ops/destroy_service_account.sh.tt +3 -3
  66. data/templates/browserslistrc +1 -2
  67. data/templates/doc/compliance/TODO.md +1 -4
  68. data/templates/{pa11yci.js → pa11yci.js.tt} +5 -0
  69. metadata +36 -35
  70. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/deploy-production.yml.tt +0 -50
  71. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/deploy-staging.yml.tt +0 -50
  72. data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/import.sh +0 -13
  73. data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/main.tf.tt +0 -22
  74. data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/providers.tf +0 -16
  75. data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/run.sh.tt +0 -40
  76. data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/teardown_creds.sh.tt +0 -5
  77. data/lib/generators/rails_template18f/terraform/templates/terraform/bootstrap/variables.tf +0 -2
  78. data/lib/generators/rails_template18f/terraform/templates/terraform/production/main.tf.tt +0 -90
  79. data/lib/generators/rails_template18f/terraform/templates/terraform/production/providers.tf +0 -23
  80. data/lib/generators/rails_template18f/terraform/templates/terraform/production/variables.tf +0 -2
  81. data/lib/generators/rails_template18f/terraform/templates/terraform/staging/main.tf.tt +0 -70
  82. data/lib/generators/rails_template18f/terraform/templates/terraform/staging/providers.tf +0 -23
  83. data/lib/generators/rails_template18f/terraform/templates/terraform/staging/variables.tf +0 -2
  84. data/lib/rails_template18f/generators/pipeline_options.rb +0 -18
  85. data/templates/app/assets/images/uswds.js +0 -6
  86. data/templates/config/deployment/production.yml +0 -3
  87. data/templates/config/deployment/staging.yml +0 -3
  88. data/templates/manifest.yml.tt +0 -17
@@ -0,0 +1,74 @@
1
+ name: Deploy Production
2
+
3
+ on:
4
+ push:
5
+ branches: [ production ]
6
+ paths-ignore:
7
+ - 'doc/**'
8
+ - 'README.md'
9
+
10
+ permissions:
11
+ contents: read
12
+ pull-requests: write
13
+
14
+ jobs:
15
+ build-assets:
16
+ name: Compile and clean assets
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+ - name: Compile assets
21
+ uses: ./.github/actions/compile-assets
22
+ with:
23
+ rails_env: production
24
+ save_cache: true
25
+ - name: Upload assets
26
+ uses: actions/upload-artifact@v4
27
+ with:
28
+ name: production-assets
29
+ path: public/assets
30
+
31
+ deploy:
32
+ name: Deploy to production
33
+ runs-on: ubuntu-latest
34
+ needs: build-assets
35
+ environment: production
36
+ env:
37
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38
+ steps:
39
+ - uses: actions/checkout@v4
40
+
41
+ - name: Download assets
42
+ uses: actions/download-artifact@v4
43
+ with:
44
+ name: production-assets
45
+ path: public/assets
46
+
47
+ - name: Terraform apply
48
+ uses: dflook/terraform-apply@v1
49
+ env:
50
+ CF_API_URL: "https://api.fr.cloud.gov"
51
+ CF_USER: ${{ secrets.CF_USERNAME }}
52
+ CF_PASSWORD: ${{ secrets.CF_PASSWORD }}
53
+ TF_VAR_cf_user: ${{ secrets.CF_USERNAME }}
54
+ TF_VAR_rails_master_key: ${{ secrets.RAILS_MASTER_KEY }}
55
+ TERRAFORM_PRE_RUN: |
56
+ apt-get update
57
+ apt-get install -y zip
58
+ with:
59
+ path: terraform
60
+ var_file: terraform/production.tfvars
61
+ backend_config: >
62
+ access_key=${{ secrets.TERRAFORM_STATE_ACCESS_KEY }}
63
+ secret_key=${{ secrets.TERRAFORM_STATE_SECRET_ACCESS_KEY }}
64
+ bucket=${{ secrets.TERRAFORM_STATE_BUCKET_NAME }}
65
+ key=terraform.tfstate.production
66
+
67
+ - name: Save app zip for debugging
68
+ if: failure()
69
+ uses: actions/upload-artifact@v4
70
+ with:
71
+ name: app-src-apply
72
+ path: terraform/dist/src.zip
73
+ compression-level: 0
74
+ retention-days: 1
@@ -0,0 +1,74 @@
1
+ name: Deploy Staging
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ paths-ignore:
7
+ - 'doc/**'
8
+ - 'README.md'
9
+
10
+ permissions:
11
+ contents: read
12
+ pull-requests: write
13
+
14
+ jobs:
15
+ build-assets:
16
+ name: Compile and clean assets
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+ - name: Compile assets
21
+ uses: ./.github/actions/compile-assets
22
+ with:
23
+ rails_env: staging
24
+ save_cache: true
25
+ - name: Upload assets
26
+ uses: actions/upload-artifact@v4
27
+ with:
28
+ name: staging-assets
29
+ path: public/assets
30
+
31
+ deploy:
32
+ name: Deploy to staging
33
+ runs-on: ubuntu-latest
34
+ needs: build-assets
35
+ environment: staging
36
+ env:
37
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38
+ steps:
39
+ - uses: actions/checkout@v4
40
+
41
+ - name: Download assets
42
+ uses: actions/download-artifact@v4
43
+ with:
44
+ name: staging-assets
45
+ path: public/assets
46
+
47
+ - name: Terraform apply
48
+ uses: dflook/terraform-apply@v1
49
+ env:
50
+ CF_API_URL: "https://api.fr.cloud.gov"
51
+ CF_USER: ${{ secrets.CF_USERNAME }}
52
+ CF_PASSWORD: ${{ secrets.CF_PASSWORD }}
53
+ TF_VAR_cf_user: ${{ secrets.CF_USERNAME }}
54
+ TF_VAR_rails_master_key: ${{ secrets.RAILS_MASTER_KEY }}
55
+ TERRAFORM_PRE_RUN: |
56
+ apt-get update
57
+ apt-get install -y zip
58
+ with:
59
+ path: terraform
60
+ var_file: terraform/staging.tfvars
61
+ backend_config: >
62
+ access_key=${{ secrets.TERRAFORM_STATE_ACCESS_KEY }}
63
+ secret_key=${{ secrets.TERRAFORM_STATE_SECRET_ACCESS_KEY }}
64
+ bucket=${{ secrets.TERRAFORM_STATE_BUCKET_NAME }}
65
+ key=terraform.tfstate.staging
66
+
67
+ - name: Save app zip for debugging
68
+ if: failure()
69
+ uses: actions/upload-artifact@v4
70
+ with:
71
+ name: app-src-apply
72
+ path: terraform/dist/src.zip
73
+ compression-level: 0
74
+ retention-days: 1
@@ -31,6 +31,15 @@ jobs:
31
31
  steps:
32
32
  - uses: actions/checkout@v4
33
33
 
34
+ - name: Touch staging cache
35
+ uses: ./.github/actions/compile-assets
36
+ with:
37
+ rails_env: staging
38
+ - name: Touch production cache
39
+ uses: ./.github/actions/compile-assets
40
+ with:
41
+ rails_env: production
42
+
34
43
  - id: setup
35
44
  uses: ./.github/actions/setup-project
36
45
 
@@ -39,7 +48,7 @@ jobs:
39
48
  database_url: ${{ steps.setup.outputs.database_url }}
40
49
 
41
50
  - name: Run OWASP Full Scan
42
- uses: zaproxy/action-full-scan@v0.10.0
51
+ uses: zaproxy/action-full-scan@v0.12.0
43
52
  with:
44
53
  token: ${{ secrets.GITHUB_TOKEN }}
45
54
  docker_name: 'ghcr.io/zaproxy/zaproxy:weekly'
@@ -38,7 +38,7 @@ jobs:
38
38
  database_url: ${{ steps.setup.outputs.database_url }}
39
39
 
40
40
  - name: Run OWASP Baseline Scan
41
- uses: zaproxy/action-baseline@v0.12.0
41
+ uses: zaproxy/action-baseline@v0.14.0
42
42
  with:
43
43
  docker_name: 'ghcr.io/zaproxy/zaproxy:weekly'
44
44
  target: 'http://localhost:3000/'
@@ -49,7 +49,7 @@ jobs:
49
49
 
50
50
  - name: Comment on pull request
51
51
  if: failure()
52
- uses: actions/github-script@v4
52
+ uses: actions/github-script@v7
53
53
  with:
54
54
  script: |
55
55
  const output = `Pa11y Failures detected
@@ -61,7 +61,7 @@ jobs:
61
61
  \`\`\`
62
62
  </details>`;
63
63
 
64
- github.issues.createComment({
64
+ github.rest.issues.createComment({
65
65
  issue_number: context.issue.number,
66
66
  owner: context.repo.owner,
67
67
  repo: context.repo.repo,
@@ -9,9 +9,28 @@ permissions:
9
9
  pull-requests: write
10
10
 
11
11
  jobs:
12
+ build-assets:
13
+ name: Compile and clean assets
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ - name: Compile assets
18
+ uses: ./.github/actions/compile-assets
19
+ with:
20
+ rails_env: production
21
+ # you may want to enable the next line to surface issues with missing assets,
22
+ # but not until after you've deployed once and the cache has been created
23
+ # fail_on_missing_cache: true
24
+ - name: Upload assets
25
+ uses: actions/upload-artifact@v4
26
+ with:
27
+ name: production-assets
28
+ path: public/assets
29
+
12
30
  terraform:
13
31
  name: Terraform plan
14
32
  runs-on: ubuntu-latest
33
+ needs: build-assets
15
34
  environment: production
16
35
  env:
17
36
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -22,20 +41,46 @@ jobs:
22
41
  - name: terraform validate
23
42
  uses: dflook/terraform-validate@v1
24
43
  with:
25
- path: terraform/production
44
+ path: terraform
26
45
 
27
46
  - name: terraform fmt
28
47
  uses: dflook/terraform-fmt-check@v1
29
48
  with:
30
- path: terraform/production
49
+ path: terraform
50
+
51
+ - name: Download assets
52
+ uses: actions/download-artifact@v4
53
+ with:
54
+ name: production-assets
55
+ path: public/assets
31
56
 
32
57
  - name: terraform plan
33
58
  uses: dflook/terraform-plan@v1
34
59
  env:
60
+ CF_API_URL: "https://api.fr.cloud.gov"
61
+ CF_USER: ${{ secrets.CF_USERNAME }}
62
+ CF_PASSWORD: ${{ secrets.CF_PASSWORD }}
35
63
  TF_VAR_cf_user: ${{ secrets.CF_USERNAME }}
36
- TF_VAR_cf_password: ${{ secrets.CF_PASSWORD }}
64
+ TF_VAR_rails_master_key: ${{ secrets.RAILS_MASTER_KEY }}
65
+ TERRAFORM_PRE_RUN: |
66
+ apt-get update
67
+ apt-get install -y zip
37
68
  with:
38
- path: terraform/production
69
+ path: terraform
70
+ var_file: terraform/production.tfvars
71
+ add_github_comment: changes-only
39
72
  backend_config: >
40
73
  access_key=${{ secrets.TERRAFORM_STATE_ACCESS_KEY }}
41
74
  secret_key=${{ secrets.TERRAFORM_STATE_SECRET_ACCESS_KEY }}
75
+ bucket=${{ secrets.TERRAFORM_STATE_BUCKET_NAME }}
76
+ key=terraform.tfstate.production
77
+
78
+ # Uncomment this step if you need to debug issues
79
+ # with mismatched app checksum between plan and apply
80
+ # - name: Save app zip for debugging
81
+ # uses: actions/upload-artifact@v4
82
+ # with:
83
+ # name: app-src-plan
84
+ # path: terraform/dist/src.zip
85
+ # compression-level: 0
86
+ # retention-days: 1
@@ -9,9 +9,28 @@ permissions:
9
9
  pull-requests: write
10
10
 
11
11
  jobs:
12
+ build-assets:
13
+ name: Compile and clean assets
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ - name: Compile assets
18
+ uses: ./.github/actions/compile-assets
19
+ with:
20
+ rails_env: staging
21
+ # you may want to enable the next line to surface issues with missing assets,
22
+ # but not until after you've deployed once and the cache has been created
23
+ # fail_on_missing_cache: true
24
+ - name: Upload assets
25
+ uses: actions/upload-artifact@v4
26
+ with:
27
+ name: staging-assets
28
+ path: public/assets
29
+
12
30
  terraform:
13
31
  name: Terraform plan
14
32
  runs-on: ubuntu-latest
33
+ needs: build-assets
15
34
  environment: staging
16
35
  env:
17
36
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -22,20 +41,46 @@ jobs:
22
41
  - name: terraform validate
23
42
  uses: dflook/terraform-validate@v1
24
43
  with:
25
- path: terraform/staging
44
+ path: terraform
26
45
 
27
46
  - name: terraform fmt
28
47
  uses: dflook/terraform-fmt-check@v1
29
48
  with:
30
- path: terraform/staging
49
+ path: terraform
50
+
51
+ - name: Download assets
52
+ uses: actions/download-artifact@v4
53
+ with:
54
+ name: staging-assets
55
+ path: public/assets
31
56
 
32
57
  - name: terraform plan
33
58
  uses: dflook/terraform-plan@v1
34
59
  env:
60
+ CF_API_URL: "https://api.fr.cloud.gov"
61
+ CF_USER: ${{ secrets.CF_USERNAME }}
62
+ CF_PASSWORD: ${{ secrets.CF_PASSWORD }}
35
63
  TF_VAR_cf_user: ${{ secrets.CF_USERNAME }}
36
- TF_VAR_cf_password: ${{ secrets.CF_PASSWORD }}
64
+ TF_VAR_rails_master_key: ${{ secrets.RAILS_MASTER_KEY }}
65
+ TERRAFORM_PRE_RUN: |
66
+ apt-get update
67
+ apt-get install -y zip
37
68
  with:
38
- path: terraform/staging
69
+ path: terraform
70
+ var_file: terraform/staging.tfvars
71
+ add_github_comment: changes-only
39
72
  backend_config: >
40
73
  access_key=${{ secrets.TERRAFORM_STATE_ACCESS_KEY }}
41
74
  secret_key=${{ secrets.TERRAFORM_STATE_SECRET_ACCESS_KEY }}
75
+ bucket=${{ secrets.TERRAFORM_STATE_BUCKET_NAME }}
76
+ key=terraform.tfstate.staging
77
+
78
+ # Uncomment this step if you need to debug issues
79
+ # with mismatched app checksum between plan and apply
80
+ # - name: Save app zip for debugging
81
+ # uses: actions/upload-artifact@v4
82
+ # with:
83
+ # name: app-src-plan
84
+ # path: terraform/dist/src.zip
85
+ # compression-level: 0
86
+ # retention-days: 1
@@ -31,14 +31,14 @@ jobs:
31
31
 
32
32
  - name: Comment on pull request
33
33
  if: failure()
34
- uses: actions/github-script@v4
34
+ uses: actions/github-script@v7
35
35
  with:
36
36
  script: |
37
37
  const output = `SSP assembly detected changes that aren't checked in.
38
38
 
39
39
  Run \`bin/trestle assemble-ssp-json\` to ensure markdown changes are reflected in your SSP`;
40
40
 
41
- github.issues.createComment({
41
+ github.rest.issues.createComment({
42
42
  issue_number: context.issue.number,
43
43
  owner: context.repo.owner,
44
44
  repo: context.repo.repo,
@@ -0,0 +1,147 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/generators"
4
+
5
+ module RailsTemplate18f
6
+ module Generators
7
+ class GitlabCiGenerator < ::Rails::Generators::Base
8
+ include Base
9
+ include CloudGovOptions
10
+
11
+ class_option :node_version, desc: "Node version to test against in actions"
12
+ class_option :postgres_version, default: "15", desc: "PostgreSQL version "
13
+
14
+ desc <<~DESC
15
+ Description:
16
+ Install GitLab CI workflow files
17
+ DESC
18
+
19
+ def install_actions
20
+ template "gitlab-ci.yml", ".gitlab-ci.yml"
21
+ directory "gitlab", ".gitlab"
22
+ end
23
+
24
+ def update_readme
25
+ if file_content("README.md").match?(/^## CI\/CD$/)
26
+ insert_into_file "README.md", readme_cicd, after: "## CI/CD\n"
27
+ insert_into_file "README.md", readme_staging_deploy, after: "#### Staging\n"
28
+ insert_into_file "README.md", readme_prod_deploy, after: "#### Production\n"
29
+ insert_into_file "README.md", readme_credentials, after: "#### Credentials and other Secrets\n"
30
+ else
31
+ append_to_file "README.md", <<~EOM
32
+ ## CI/CD
33
+ #{readme_cicd}
34
+
35
+ ### Deployment
36
+
37
+ #### Staging
38
+ #{readme_staging_deploy}
39
+
40
+ #### Production
41
+ #{readme_prod_deploy}
42
+
43
+ #### Credentials and other Secrets
44
+ #{readme_credentials}
45
+ EOM
46
+ end
47
+ end
48
+
49
+ def update_boundary_diagram
50
+ boundary_filename = "doc/compliance/apps/application.boundary.md"
51
+ insert_into_file boundary_filename, <<EOB, after: "Boundary(cicd, \"CI/CD Pipeline\") {\n"
52
+ System_Ext(gitlabci, "GitLab w/ DevTools Runner", "GSA-controlled code repository and Continuous Integration Service")
53
+ EOB
54
+ insert_into_file boundary_filename, <<~EOB, before: "@enduml"
55
+ Rel(developer, gitlabci, "Publish code", "git ssh (22)")
56
+ Rel(gitlabci, cg_api, "Deploy App", "Auth: SpaceDeployer Service Account, https (443)")
57
+ EOB
58
+ end
59
+
60
+ no_tasks do
61
+ def readme_cicd
62
+ <<~EOM
63
+
64
+ GitLab CI is used to run all tests and scans as part of pull requests.
65
+
66
+ Security scans are also run on a scheduled basis. DEVELOPER TODO: create a pipeline schedule in the GitLab UI and update this sentence with the cadence.
67
+ EOM
68
+ end
69
+
70
+ def readme_staging_deploy
71
+ <<~EOM
72
+
73
+ Deploys to staging happen via terraform on every push to the `main` branch in GitLab.
74
+
75
+ The following secrets must be set within the masked and hidden [CI/CD variables](https://docs.gitlab.com/ci/variables/)
76
+
77
+ | Secret Name | Description |
78
+ | ----------- | ----------- |
79
+ | `CF_USERNAME` | cloud.gov SpaceDeployer username |
80
+ | `CF_PASSWORD` | cloud.gov SpaceDeployer password |
81
+ | `RAILS_MASTER_KEY` | `config/master.key` |
82
+ #{terraform_secret_values}
83
+ EOM
84
+ end
85
+
86
+ def readme_prod_deploy
87
+ if terraform_manage_spaces?
88
+ <<~EOM
89
+
90
+ Deploys to production happen via terraform on every push to the `production` branch in GitLab.
91
+
92
+ The following secrets must be set within the masked and hidden [CI/CD variables](https://docs.gitlab.com/ci/variables/)
93
+
94
+ | Secret Name | Description |
95
+ | ----------- | ----------- |
96
+ | `CF_USERNAME` | cloud.gov SpaceDeployer username |
97
+ | `CF_PASSWORD` | cloud.gov SpaceDeployer password |
98
+ | `PRODUCTION_RAILS_MASTER_KEY` | `config/credentials/production.key`. Should be marked as `Protected`. |
99
+ #{terraform_secret_values}
100
+ EOM
101
+ else
102
+ "Production deploys are not supported in the sandbox organization."
103
+ end
104
+ end
105
+
106
+ def readme_credentials
107
+ <<~EOM
108
+
109
+ 1. Store variables that must be secret using masked and hidden [CI/CD variables](https://docs.gitlab.com/ci/variables/) in GitLab
110
+ 1. Add the appropriate `-var` arguments to the `terraform:plan:<env>` and `terraform:apply:<env>` jobs like the existing `-var rails_master_key=`
111
+ EOM
112
+ end
113
+ end
114
+
115
+ private
116
+
117
+ def terraform_secret_values
118
+ <<~EOM
119
+ | `TERRAFORM_PUBLIC_BACKEND_CONFIG` | File-type variable containing all entries from secrets.backend.tfvars _except_ `secret_key`. Marked as `Visible` |
120
+ | `TERRAFORM_SECRET_BACKEND_CONFIG` | File-type variable containing the `secret_key` line from secrets.backend.tfvars. Masked and hidden. |
121
+ EOM
122
+ end
123
+
124
+ def postgres_version
125
+ options[:postgres_version]
126
+ end
127
+
128
+ def node_version
129
+ if options[:node_version].present?
130
+ options[:node_version]
131
+ elsif File.exist?(nvmrc_path)
132
+ File.read(nvmrc_path).strip
133
+ else
134
+ "20.16"
135
+ end
136
+ end
137
+
138
+ def node_major
139
+ node_version.split(".").first
140
+ end
141
+
142
+ def nvmrc_path
143
+ @nvmrc_path ||= File.expand_path(".nvmrc", destination_root)
144
+ end
145
+ end
146
+ end
147
+ end
@@ -0,0 +1,11 @@
1
+ .setup-node:
2
+ - curl -fsSL https://deb.nodesource.com/setup_<%= node_major %>.x -o nodesource_setup.sh
3
+ - bash nodesource_setup.sh
4
+ - apt-get install -y nodejs
5
+ - npm install --global yarn
6
+
7
+ .yarn-install:
8
+ - PUPPETEER_SKIP_DOWNLOAD=true yarn install --frozen-lockfile --no-progress
9
+
10
+ .install-puppet-deps:
11
+ - apt-get update && apt-get install -y chromium
@@ -0,0 +1,75 @@
1
+ include:
2
+ - local: ".gitlab/ruby.yml"
3
+ - local: ".gitlab/node.yml"
4
+
5
+ # Cache Helpers
6
+ .cache-dependencies:
7
+ variables:
8
+ WORKER_MEMORY: 2G
9
+ cache:
10
+ key:
11
+ files:
12
+ - Gemfile.lock
13
+ - yarn.lock
14
+ prefix: dependencies
15
+ paths:
16
+ - vendor/ruby
17
+ - node_modules/
18
+ policy: pull
19
+
20
+ # Language Helpers
21
+ .setup-languages:
22
+ before_script:
23
+ - !reference [.setup-ruby]
24
+ - !reference [.setup-node]
25
+
26
+ # Project Helpers
27
+ .setup-project:
28
+ services:
29
+ - name: "postgres:${POSTGRES_VERSION}"
30
+ alias: pg
31
+ before_script:
32
+ - !reference [.setup-ruby]
33
+ - export DATABASE_URL="postgres://postgres:${POSTGRES_PASSWORD}@${CI_SERVICE_pg}:5432/${POSTGRES_DB}"
34
+ - bin/rails db:prepare
35
+
36
+ .run-server:
37
+ extends: .setup-project
38
+ dependencies: []
39
+ variables:
40
+ RAILS_ENV: ci
41
+ SECRET_KEY_BASE_DUMMY: 1
42
+ before_script:
43
+ - !reference [.setup-node]
44
+ - !reference [.setup-project, before_script]
45
+ - bin/rake assets:precompile
46
+ - PORT=3000 bin/rails server > /dev/null 2>&1 &
47
+ - sleep 5
48
+
49
+ .owasp:setup:
50
+ stage: test
51
+ extends: .run-server
52
+ image: "rcahearngsa/owasp-ruby:${RUBY_VERSION}"
53
+ variables:
54
+ WORKER_MEMORY: 3G
55
+ WORKER_DISK: 6G
56
+ before_script:
57
+ - !reference [.run-server, before_script]
58
+ - ln -s $PWD /zap/wrk
59
+ artifacts:
60
+ expose_as: "OWASP Report"
61
+ paths:
62
+ - zap_report.html
63
+
64
+ .assets:builder:
65
+ stage: deploy
66
+ extends: .setup-languages
67
+ dependencies: []
68
+ variables:
69
+ SECRET_KEY_BASE_DUMMY: 1
70
+ script:
71
+ - bin/rake assets:precompile
72
+ - bin/rake assets:clean
73
+ artifacts:
74
+ paths:
75
+ - public/assets
@@ -0,0 +1,7 @@
1
+ .setup-ruby:
2
+ - export PATH=$PATH:/usr/local/bundle/bin
3
+ - bundle config set --local path 'vendor/ruby'
4
+ - bundle config set --local deployment true
5
+
6
+ .bundle-install:
7
+ - bundle install
@@ -0,0 +1,28 @@
1
+ # Shared setup helpers for terraform jobs
2
+ .terraform:setup:
3
+ stage: deploy
4
+ inherit:
5
+ default: false
6
+ image:
7
+ name: "hashicorp/terraform"
8
+ entrypoint: ["sh"]
9
+ variables:
10
+ CF_API_URL: https://api.fr.cloud.gov
11
+ TERRAFORM_BACKEND_KEY: terraform.tfstate.staging
12
+ dependencies: []
13
+ before_script:
14
+ - cd terraform
15
+ - terraform init -backend-config=$TERRAFORM_PUBLIC_BACKEND_CONFIG -backend-config=$TERRAFORM_SECRET_BACKEND_CONFIG -backend-config="key=$TERRAFORM_BACKEND_KEY"
16
+ rules:
17
+ - if: $CI_PIPELINE_SOURCE != "schedule"
18
+
19
+ .terraform:variables:staging:
20
+ dependencies: null
21
+ variables:
22
+ CF_USER: $CF_USERNAME
23
+
24
+ .terraform:variables:production:
25
+ dependencies: null
26
+ variables:
27
+ CF_USER: $CF_USERNAME
28
+ TERRAFORM_BACKEND_KEY: terraform.tfstate.production