rails_template_18f 2.0.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 (32) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/Gemfile.lock +6 -6
  4. data/lib/generators/rails_template18f/circleci/templates/circleci/config.yml.tt +12 -2
  5. data/lib/generators/rails_template18f/cloud_gov_config/templates/app/models/cloud_gov_config.rb +9 -1
  6. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/deploy-production.yml +3 -1
  7. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/deploy-staging.yml +3 -1
  8. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/terraform-production.yml +3 -1
  9. data/lib/generators/rails_template18f/github_actions/templates/github/workflows/terraform-staging.yml +3 -1
  10. data/lib/generators/rails_template18f/gitlab_ci/gitlab_ci_generator.rb +147 -0
  11. data/lib/generators/rails_template18f/gitlab_ci/templates/gitlab/node.yml.tt +11 -0
  12. data/lib/generators/rails_template18f/gitlab_ci/templates/gitlab/rails.yml +75 -0
  13. data/lib/generators/rails_template18f/gitlab_ci/templates/gitlab/ruby.yml +7 -0
  14. data/lib/generators/rails_template18f/gitlab_ci/templates/gitlab/terraform.yml +28 -0
  15. data/lib/generators/rails_template18f/gitlab_ci/templates/gitlab-ci.yml.tt +212 -0
  16. data/lib/generators/rails_template18f/public_egress/public_egress_generator.rb +15 -31
  17. data/lib/generators/rails_template18f/terraform/templates/full_bootstrap/main.tf.tt +2 -2
  18. data/lib/generators/rails_template18f/terraform/templates/sandbox_bootstrap/main.tf.tt +1 -1
  19. data/lib/generators/rails_template18f/terraform/templates/terraform/README.md.tt +3 -13
  20. data/lib/generators/rails_template18f/terraform/templates/terraform/app.tf.tt +0 -6
  21. data/lib/generators/rails_template18f/terraform/templates/terraform/main.tf.tt +27 -16
  22. data/lib/generators/rails_template18f/terraform/templates/terraform/production.tfvars.tt +3 -0
  23. data/lib/generators/rails_template18f/terraform/templates/terraform/providers.tf.tt +7 -21
  24. data/lib/generators/rails_template18f/terraform/templates/terraform/terraform.sh.tt +1 -41
  25. data/lib/generators/rails_template18f/terraform/templates/terraform/variables.tf.tt +8 -9
  26. data/lib/generators/rails_template18f/terraform/terraform_generator.rb +0 -1
  27. data/lib/rails_template18f/version.rb +1 -1
  28. data/template.rb +20 -12
  29. data/templates/{pa11yci.js → pa11yci.js.tt} +5 -0
  30. metadata +10 -10
  31. data/lib/generators/rails_template18f/terraform/templates/terraform/sandbox_bot/main.tf +0 -74
  32. data/lib/generators/rails_template18f/terraform/templates/terraform/sandbox_bot/run.sh +0 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3286e663d05b9b712a5b1f3fa2aa1403016f0822be9fd26d0999200701dab318
4
- data.tar.gz: 04e5124a24452f747270e42aaa1b5455de3b0ce4362ff455e94554984214473e
3
+ metadata.gz: c98e855c8844d55ba478f2fe9a0bac27cea41e417e7f76b2be22f97c5363963c
4
+ data.tar.gz: 5eeb6079ee3d68350ee473aec5156fd54f2f47d837a1230ac62080b223960220
5
5
  SHA512:
6
- metadata.gz: 954b939ea264b5200c01e8122da1001e0c099f072b370de98926ce9dcaef154a6e00568353a4fff191addfaf1cd7cc4f85549454c6984b29ff9c537af8207f17
7
- data.tar.gz: c85daa74d0ca528fbbe4a3d260a720206194635a12c6a73fde878e19384870a601e78f789b513c43bfd57c4290ef6e6f85bcb409717ad646628ca1966318e09b
6
+ metadata.gz: 24df2ba12417ab9754e851406fc9c77b21c23b21206f7760dd0ba23d0793f25b3fad5c8a57fbf2c5f9743cb8e0edd2bbe6a89b4f8603342f9ec893f3a28bdb34
7
+ data.tar.gz: 681823d0918b7ddacde8372051d85f8636954b92aa97467655b89e7d5ac3580768b31d1b7e12d27cd8d2a296c92769ae065b578dbb1b143aa8dbb15e9927fcde
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [2.1.0] - 2025-04-29
4
+
5
+ - Terraform generator updates to remove the old cloudfoundy-community provider and reduce the need for cloud.gov service accounts
6
+ - New GitLab CI generator for use with DevTools GitLab
7
+
3
8
  ## [2.0.0] - 2025-01-16
4
9
 
5
10
  - Default new apps to Rails 8, including support for thruster proxy
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails_template_18f (2.0.0)
4
+ rails_template_18f (2.1.0)
5
5
  activesupport (~> 8.0.1)
6
6
  colorize (~> 1.1)
7
7
  railties (~> 8.0.1)
@@ -71,11 +71,11 @@ GEM
71
71
  crass (~> 1.0.2)
72
72
  nokogiri (>= 1.12.0)
73
73
  minitest (5.25.4)
74
- nokogiri (1.18.0-arm64-darwin)
74
+ nokogiri (1.18.8-arm64-darwin)
75
75
  racc (~> 1.4)
76
- nokogiri (1.18.0-x86_64-darwin)
76
+ nokogiri (1.18.8-x86_64-darwin)
77
77
  racc (~> 1.4)
78
- nokogiri (1.18.0-x86_64-linux-gnu)
78
+ nokogiri (1.18.8-x86_64-linux-gnu)
79
79
  racc (~> 1.4)
80
80
  parallel (1.26.3)
81
81
  parser (3.3.6.0)
@@ -85,7 +85,7 @@ GEM
85
85
  date
86
86
  stringio
87
87
  racc (1.8.1)
88
- rack (3.1.8)
88
+ rack (3.1.12)
89
89
  rack-session (2.0.0)
90
90
  rack (>= 3.0.0)
91
91
  rack-test (2.2.0)
@@ -171,7 +171,7 @@ GEM
171
171
  unicode-display_width (3.1.3)
172
172
  unicode-emoji (~> 4.0, >= 4.0.4)
173
173
  unicode-emoji (4.0.4)
174
- uri (1.0.2)
174
+ uri (1.0.3)
175
175
  useragent (0.16.11)
176
176
  zeitwerk (2.7.1)
177
177
 
@@ -314,13 +314,15 @@ jobs:
314
314
  - attach_workspace:
315
315
  at: .
316
316
  - terraform/plan:
317
+ environment:
318
+ CF_API_URL: "https://api.fr.cloud.gov"
319
+ CF_USER: "$CF_USERNAME"
317
320
  path: terraform
318
321
  out: staging.out
319
322
  var_file: staging.tfvars
320
323
  var: >-
321
324
  rails_master_key="$RAILS_MASTER_KEY",
322
325
  cf_user="$CF_USERNAME",
323
- cf_password="$CF_PASSWORD"
324
326
  - persist_to_workspace:
325
327
  root: .
326
328
  paths:
@@ -332,6 +334,9 @@ jobs:
332
334
  - attach_workspace:
333
335
  at: .
334
336
  - terraform/apply:
337
+ environment:
338
+ CF_API_URL: "https://api.fr.cloud.gov"
339
+ CF_USER: "$CF_USERNAME"
335
340
  path: terraform
336
341
  plan: staging.out<% if terraform_manage_spaces? %>
337
342
 
@@ -358,13 +363,15 @@ jobs:
358
363
  - attach_workspace:
359
364
  at: .
360
365
  - terraform/plan:
366
+ environment:
367
+ CF_API_URL: "https://api.fr.cloud.gov"
368
+ CF_USER: "$CF_USERNAME"
361
369
  path: terraform
362
370
  out: production.out
363
371
  var_file: production.tfvars
364
372
  var: >-
365
373
  rails_master_key="$PRODUCTION_RAILS_MASTER_KEY",
366
374
  cf_user="$CF_USERNAME",
367
- cf_password="$CF_PASSWORD"
368
375
  - persist_to_workspace:
369
376
  root: .
370
377
  paths:
@@ -376,6 +383,9 @@ jobs:
376
383
  - attach_workspace:
377
384
  at: .
378
385
  - terraform/apply:
386
+ environment:
387
+ CF_API_URL: "https://api.fr.cloud.gov"
388
+ CF_USER: "$CF_USERNAME"
379
389
  path: terraform
380
390
  plan: production.out<% end %>
381
391
 
@@ -10,6 +10,14 @@ class CloudGovConfig
10
10
  end
11
11
 
12
12
  def self.vcap_services
13
- @vcap_services ||= JSON.parse(ENV[ENV_VARIABLE]).with_indifferent_access
13
+ if Rails.env.test?
14
+ parse_env
15
+ else
16
+ @vcap_services ||= parse_env
17
+ end
18
+ end
19
+
20
+ private_class_method def self.parse_env
21
+ JSON.parse(ENV[ENV_VARIABLE]).with_indifferent_access
14
22
  end
15
23
  end
@@ -47,8 +47,10 @@ jobs:
47
47
  - name: Terraform apply
48
48
  uses: dflook/terraform-apply@v1
49
49
  env:
50
+ CF_API_URL: "https://api.fr.cloud.gov"
51
+ CF_USER: ${{ secrets.CF_USERNAME }}
52
+ CF_PASSWORD: ${{ secrets.CF_PASSWORD }}
50
53
  TF_VAR_cf_user: ${{ secrets.CF_USERNAME }}
51
- TF_VAR_cf_password: ${{ secrets.CF_PASSWORD }}
52
54
  TF_VAR_rails_master_key: ${{ secrets.RAILS_MASTER_KEY }}
53
55
  TERRAFORM_PRE_RUN: |
54
56
  apt-get update
@@ -47,8 +47,10 @@ jobs:
47
47
  - name: Terraform apply
48
48
  uses: dflook/terraform-apply@v1
49
49
  env:
50
+ CF_API_URL: "https://api.fr.cloud.gov"
51
+ CF_USER: ${{ secrets.CF_USERNAME }}
52
+ CF_PASSWORD: ${{ secrets.CF_PASSWORD }}
50
53
  TF_VAR_cf_user: ${{ secrets.CF_USERNAME }}
51
- TF_VAR_cf_password: ${{ secrets.CF_PASSWORD }}
52
54
  TF_VAR_rails_master_key: ${{ secrets.RAILS_MASTER_KEY }}
53
55
  TERRAFORM_PRE_RUN: |
54
56
  apt-get update
@@ -57,8 +57,10 @@ jobs:
57
57
  - name: terraform plan
58
58
  uses: dflook/terraform-plan@v1
59
59
  env:
60
+ CF_API_URL: "https://api.fr.cloud.gov"
61
+ CF_USER: ${{ secrets.CF_USERNAME }}
62
+ CF_PASSWORD: ${{ secrets.CF_PASSWORD }}
60
63
  TF_VAR_cf_user: ${{ secrets.CF_USERNAME }}
61
- TF_VAR_cf_password: ${{ secrets.CF_PASSWORD }}
62
64
  TF_VAR_rails_master_key: ${{ secrets.RAILS_MASTER_KEY }}
63
65
  TERRAFORM_PRE_RUN: |
64
66
  apt-get update
@@ -57,8 +57,10 @@ jobs:
57
57
  - name: terraform plan
58
58
  uses: dflook/terraform-plan@v1
59
59
  env:
60
+ CF_API_URL: "https://api.fr.cloud.gov"
61
+ CF_USER: ${{ secrets.CF_USERNAME }}
62
+ CF_PASSWORD: ${{ secrets.CF_PASSWORD }}
60
63
  TF_VAR_cf_user: ${{ secrets.CF_USERNAME }}
61
- TF_VAR_cf_password: ${{ secrets.CF_PASSWORD }}
62
64
  TF_VAR_rails_master_key: ${{ secrets.RAILS_MASTER_KEY }}
63
65
  TERRAFORM_PRE_RUN: |
64
66
  apt-get update
@@ -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
@@ -0,0 +1,212 @@
1
+ # Note that environment variables can be set in several places
2
+ # See https://docs.gitlab.com/ee/ci/variables/#cicd-variable-precedence
3
+
4
+ workflow:
5
+ rules:
6
+ - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
7
+ - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
8
+ - if: $CI_COMMIT_BRANCH == "production"
9
+
10
+ stages:
11
+ - build
12
+ - test
13
+ - deploy
14
+
15
+ variables:
16
+ POSTGRES_DB: <%= app_name %>_test
17
+ POSTGRES_PASSWORD: not-actually-secret
18
+ POSTGRES_VERSION: <%= postgres_version %>
19
+ RUBY_VERSION: <%= RUBY_VERSION %>
20
+
21
+ include:
22
+ - local: ".gitlab/ruby.yml"
23
+ - local: ".gitlab/node.yml"
24
+ - local: ".gitlab/rails.yml"
25
+ - local: ".gitlab/terraform.yml"
26
+
27
+ default:
28
+ image: "ruby:${RUBY_VERSION}"
29
+ before_script:
30
+ - !reference [.setup-ruby]
31
+ cache:
32
+ - !reference [.cache-dependencies, cache]
33
+
34
+ build-project:
35
+ stage: build
36
+ extends: [.cache-dependencies, .setup-languages]
37
+ cache:
38
+ policy: pull-push
39
+ script:
40
+ - !reference [.bundle-install]
41
+ - !reference [.yarn-install]
42
+ - bin/rake assets:precompile
43
+ artifacts:
44
+ expire_in: 1 hour
45
+ paths:
46
+ - app/assets/builds
47
+ - public/assets
48
+ rules:
49
+ - if: $CI_PIPELINE_SOURCE != "schedule"
50
+
51
+ brakeman-scan:
52
+ stage: test
53
+ script:
54
+ - bin/brakeman --no-pager --ensure-ignore-notes -f sarif -o output.sarif.json
55
+ artifacts:
56
+ when: always
57
+ expose_as: "Brakeman results"
58
+ paths:
59
+ - output.sarif.json
60
+
61
+ dependency_scanning:
62
+ stage: test
63
+ extends: .setup-languages
64
+ script:
65
+ - bin/rake bundler:audit
66
+ - bin/rake yarn:audit
67
+ - gem install cyclonedx-ruby
68
+ - cyclonedx-ruby -p . -o ruby_bom.xml
69
+ artifacts:
70
+ expose_as: "Ruby SBOM"
71
+ paths:
72
+ - ruby_bom.xml
73
+
74
+ rspec:
75
+ stage: test
76
+ extends: .setup-project
77
+ script:
78
+ - bundle exec rspec
79
+ rules:
80
+ - if: $CI_PIPELINE_SOURCE != "schedule"
81
+
82
+ pa11y_scan:
83
+ stage: test
84
+ extends: .run-server
85
+ script:
86
+ - !reference [.install-puppet-deps]
87
+ - yarn run pa11y-ci -c pa11yci.js
88
+ rules:
89
+ - if: $CI_PIPELINE_SOURCE != "schedule"
90
+
91
+ owasp_scan:
92
+ extends: .owasp:setup
93
+ script:
94
+ - /zap/zap-baseline.py -t http://localhost:3000 -c zap.conf -I -r zap_report.html
95
+ rules:
96
+ - if: $CI_PIPELINE_SOURCE != "schedule"
97
+
98
+ owasp_daily_scan:
99
+ extends: .owasp:setup
100
+ script:
101
+ - /zap/zap-full-scan.py -t http://localhost:3000 -c zap.conf -I -r zap_report.html
102
+ rules:
103
+ - if: $CI_PIPELINE_SOURCE == "schedule"
104
+
105
+ terraform:fmt:
106
+ stage: test
107
+ extends: .terraform:setup
108
+ script:
109
+ - terraform fmt -check -recursive .
110
+
111
+ terraform:validate:
112
+ stage: test
113
+ extends: .terraform:setup
114
+ script:
115
+ - terraform validate
116
+
117
+ terraform:assets:staging:
118
+ extends: .assets:builder
119
+ cache:
120
+ - !reference [.cache-dependencies, cache]
121
+ - key: staging-assets
122
+ unprotect: true
123
+ paths:
124
+ - public/assets
125
+ - app/assets/builds
126
+ policy: $CACHE_POLICY
127
+ variables:
128
+ RAILS_ENV: staging
129
+ rules:
130
+ - if: $CI_PIPELINE_SOURCE == "schedule"
131
+ when: never
132
+ - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
133
+ variables:
134
+ CACHE_POLICY: pull-push
135
+ - variables:
136
+ CACHE_POLICY: pull
137
+ <% if terraform_manage_spaces? %>
138
+ terraform:assets:production:
139
+ extends: .assets:builder
140
+ cache:
141
+ - !reference [.cache-dependencies, cache]
142
+ - key: production-assets
143
+ paths:
144
+ - public/assets
145
+ - app/assets/builds
146
+ policy: $CACHE_POLICY
147
+ variables:
148
+ RAILS_ENV: production
149
+ rules:
150
+ - if: $CI_COMMIT_BRANCH == "production"
151
+ variables:
152
+ CACHE_POLICY: pull-push
153
+ - if: $CI_PIPELINE_SOURCE != "schedule"
154
+ variables:
155
+ CACHE_POLICY: pull
156
+ <% end %>
157
+ terraform:plan:staging:
158
+ extends:
159
+ - .terraform:setup
160
+ - .terraform:variables:staging
161
+ needs: ["terraform:assets:staging"]
162
+ script:
163
+ - apk add zip
164
+ - terraform plan -out=staging_plan.out -var-file=staging.tfvars -var rails_master_key=$RAILS_MASTER_KEY -var cf_user=$CF_USERNAME
165
+ artifacts:
166
+ paths:
167
+ - terraform/staging_plan.out
168
+ - terraform/dist
169
+
170
+ terraform:apply:staging:
171
+ extends:
172
+ - .terraform:setup
173
+ - .terraform:variables:staging
174
+ needs:
175
+ - terraform:plan:staging
176
+ - terraform:assets:staging
177
+ script:
178
+ - apk add zip
179
+ - terraform apply -var-file=staging.tfvars -var rails_master_key=$RAILS_MASTER_KEY -var cf_user=$CF_USERNAME staging_plan.out
180
+ rules:
181
+ - if: $CI_PIPELINE_SOURCE == "schedule"
182
+ when: never
183
+ - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
184
+ <% if terraform_manage_spaces? %>
185
+ terraform:plan:production:
186
+ extends:
187
+ - .terraform:setup
188
+ - .terraform:variables:production
189
+ needs: ["terraform:assets:production"]
190
+ script:
191
+ - apk add zip
192
+ - terraform plan -out=production_plan.out -var-file=production.tfvars -var rails_master_key=$PRODUCTION_RAILS_MASTER_KEY -var cf_user=$CF_USERNAME
193
+ artifacts:
194
+ paths:
195
+ - terraform/production_plan.out
196
+ - terraform/dist
197
+
198
+ terraform:apply:production:
199
+ extends:
200
+ - .terraform:setup
201
+ - .terraform:variables:production
202
+ needs:
203
+ - terraform:plan:production
204
+ - terraform:assets:production
205
+ script:
206
+ - apk add zip
207
+ - terraform apply -var-file=production.tfvars -var rails_master_key=$PRODUCTION_RAILS_MASTER_KEY -var cf_user=$CF_USERNAME production_plan.out
208
+ rules:
209
+ - if: $CI_PIPELINE_SOURCE == "schedule"
210
+ when: never
211
+ - if: $CI_COMMIT_BRANCH == "production"
212
+ when: manual<% end %>