Add notices tasks and workflow
This commit is contained in:
parent
5ceb05e6c3
commit
8e39ec6c49
4 changed files with 185 additions and 28 deletions
111
.github/workflows/full_build.yml
vendored
Normal file
111
.github/workflows/full_build.yml
vendored
Normal file
|
@ -0,0 +1,111 @@
|
||||||
|
name: Houdini build
|
||||||
|
on: [push, pull_request]
|
||||||
|
jobs:
|
||||||
|
notice_ruby:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Set up Ruby
|
||||||
|
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
||||||
|
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
||||||
|
# uses: ruby/setup-ruby@v1
|
||||||
|
uses: ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0
|
||||||
|
- uses: actions/cache@v1
|
||||||
|
name: Use Gem cache
|
||||||
|
with:
|
||||||
|
path: vendor/bundle
|
||||||
|
key: bundle-use-ruby-ubuntu-latest-2.6.6-${{ hashFiles('**/Gemfile.lock') }}
|
||||||
|
restore-keys: |
|
||||||
|
bundle-use-ruby-ubuntu-latest-2.6.6-
|
||||||
|
- name: bundle install
|
||||||
|
run: |
|
||||||
|
bundle config deployment true
|
||||||
|
bundle config path vendor/bundle
|
||||||
|
bundle install --jobs 4
|
||||||
|
- name: run notice:ruby:verify
|
||||||
|
run: |
|
||||||
|
bin/rails notice:ruby:verify
|
||||||
|
notice_js:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: notice_ruby
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Set up Ruby
|
||||||
|
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
||||||
|
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
||||||
|
# uses: ruby/setup-ruby@v1
|
||||||
|
uses: ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0
|
||||||
|
- name: Setup Node.js environment
|
||||||
|
uses: actions/setup-node@v1.4.2
|
||||||
|
- uses: actions/cache@v1
|
||||||
|
name: Use Node package cache
|
||||||
|
with:
|
||||||
|
path: node_modules
|
||||||
|
key: bundle-use-node-js-ubuntu-latest-12-${{ hashFiles('**/yarn.lock') }}
|
||||||
|
restore-keys: |
|
||||||
|
bundle-use-node-js-ubuntu-latest-12-
|
||||||
|
- uses: actions/cache@v1
|
||||||
|
name: Use Gem cache
|
||||||
|
with:
|
||||||
|
path: vendor/bundle
|
||||||
|
key: bundle-use-ruby-ubuntu-latest-2.6.6-${{ hashFiles('**/Gemfile.lock') }}
|
||||||
|
restore-keys: |
|
||||||
|
bundle-use-ruby-ubuntu-latest-2.6.6-
|
||||||
|
- name: bundle install
|
||||||
|
run: |
|
||||||
|
bundle config deployment true
|
||||||
|
bundle config path vendor/bundle
|
||||||
|
bundle install --jobs 4
|
||||||
|
- name: install node packages
|
||||||
|
run: yarn install --frozen-lockfile
|
||||||
|
- name: run notice:js:verify
|
||||||
|
run: |
|
||||||
|
bin/rails notice:js:verify
|
||||||
|
main_build:
|
||||||
|
needs: [notice_js]
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest]
|
||||||
|
node: [12]
|
||||||
|
ruby: [2.6.6]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Setup PostgreSQL with PostgreSQL extensions and unprivileged user
|
||||||
|
uses: Daniel-Marynicz/postgresql-action@0.1.0
|
||||||
|
with:
|
||||||
|
postgres_image_tag: 11-alpine
|
||||||
|
postgres_user: houdini_user
|
||||||
|
postgres_password: password
|
||||||
|
- name: Set up Ruby
|
||||||
|
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
||||||
|
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
||||||
|
# uses: ruby/setup-ruby@v1
|
||||||
|
uses: ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0
|
||||||
|
- name: Setup Node.js environment
|
||||||
|
uses: actions/setup-node@v1.4.2
|
||||||
|
- uses: actions/cache@v1
|
||||||
|
name: Use Gem cache
|
||||||
|
with:
|
||||||
|
path: vendor/bundle
|
||||||
|
key: bundle-use-ruby-${{ matrix.os }}-${{ matrix.ruby }}-${{ hashFiles('**/Gemfile.lock') }}
|
||||||
|
restore-keys: |
|
||||||
|
bundle-use-ruby-${{ matrix.os }}-${{ matrix.ruby }}-
|
||||||
|
- name: bundle install
|
||||||
|
run: |
|
||||||
|
bundle config deployment true
|
||||||
|
bundle config path vendor/bundle
|
||||||
|
bundle install --jobs 4
|
||||||
|
- uses: actions/cache@v1
|
||||||
|
name: Use Node package cache
|
||||||
|
with:
|
||||||
|
path: node_modules
|
||||||
|
key: bundle-use-node-js-${{ matrix.os }}-${{ matrix.node }}-${{ hashFiles('**/yarn.lock') }}
|
||||||
|
restore-keys: |
|
||||||
|
bundle-use-node-js-${{ matrix.os }}-${{ matrix.node }}-
|
||||||
|
- name: run setup
|
||||||
|
run: bin/setup ci
|
||||||
|
- name: run spec
|
||||||
|
run: bin/rails spec
|
||||||
|
- name: run jest
|
||||||
|
run: yarn jest
|
11
bin/setup
11
bin/setup
|
@ -19,15 +19,24 @@ FileUtils.chdir APP_ROOT do
|
||||||
system('bundle check') || system!('bundle install')
|
system('bundle check') || system!('bundle install')
|
||||||
|
|
||||||
puts "\n== Installing dependencies (JS) =="
|
puts "\n== Installing dependencies (JS) =="
|
||||||
|
yarn_cmd = 'yarn -s'
|
||||||
|
if ARGV.length > 0 && ARGV[0] == 'ci'
|
||||||
|
yarn_cmd += " --frozen-lockfile"
|
||||||
|
end
|
||||||
system!('yarn -s')
|
system!('yarn -s')
|
||||||
|
|
||||||
|
|
||||||
|
if ARGV.length == 0 || (ARGV.length > 0 && ARGV[0] != 'ci')
|
||||||
puts "\n== Copying env file =="
|
puts "\n== Copying env file =="
|
||||||
unless File.exist?('.env')
|
unless File.exist?('.env')
|
||||||
FileUtils.cp '.env.template', '.env'
|
FileUtils.cp '.env.template', '.env'
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "\n== Create new secrets =="
|
puts "\n== Create new secrets =="
|
||||||
File.write('.env', File.read('.env').gsub(/-- secret string --/) { SecureRandom.hex(64) })
|
File.write('.env', File.read('.env').gsub(/-- secret string --/) { SecureRandom.hex(64) })
|
||||||
|
else
|
||||||
|
puts "\n== Copying env file =="
|
||||||
|
FileUtils.cp '.env.test', '.env'
|
||||||
|
end
|
||||||
|
|
||||||
puts "\n== Preparing database =="
|
puts "\n== Preparing database =="
|
||||||
system! 'bin/rails db:prepare'
|
system! 'bin/rails db:prepare'
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
desc "generating a notice for bundler"
|
|
||||||
|
|
||||||
# Clear old activerecord sessions tables daily
|
|
||||||
task :bundler_notice => :environment do
|
|
||||||
require 'bundler'
|
|
||||||
require 'httparty'
|
|
||||||
parser = Bundler::LockfileParser.new(File.read(Rails.root.join("Gemfile.lock")))
|
|
||||||
result = parser.specs.map do |spec|
|
|
||||||
"gem/rubygems/-/#{spec.name}/#{spec.version.to_s}"
|
|
||||||
end
|
|
||||||
|
|
||||||
@options = {
|
|
||||||
:headers => {
|
|
||||||
'Content-Type' => 'application/json',
|
|
||||||
'Accept' => 'application/json'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
result = HTTParty.post("https://api.clearlydefined.io/notices", @options.merge(body:JSON::generate({coordinates: result})))
|
|
||||||
byebug
|
|
||||||
end
|
|
59
lib/tasks/notice.rake
Normal file
59
lib/tasks/notice.rake
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
|
|
||||||
|
# Create notice files for dependencies
|
||||||
|
namespace :notice do
|
||||||
|
namespace :ruby do
|
||||||
|
require 'bundler'
|
||||||
|
require 'httparty'
|
||||||
|
def get_notice_ruby
|
||||||
|
parser = Bundler::LockfileParser.new(File.read(Rails.root.join("Gemfile.lock")))
|
||||||
|
result = parser.specs.map do |spec|
|
||||||
|
"gem/rubygems/-/#{spec.name}/#{spec.version.to_s}"
|
||||||
|
end
|
||||||
|
|
||||||
|
@options = {
|
||||||
|
:headers => {
|
||||||
|
'Content-Type' => 'application/json',
|
||||||
|
'Accept' => 'application/json'
|
||||||
|
},
|
||||||
|
:timeout => 120
|
||||||
|
}
|
||||||
|
result = HTTParty.post("https://api.clearlydefined.io/notices", @options.merge(body:JSON::generate({coordinates: result})))
|
||||||
|
end
|
||||||
|
|
||||||
|
desc "generating NOTICE-ruby from ClearlyDefined.io"
|
||||||
|
task :update do
|
||||||
|
result = get_notice_ruby
|
||||||
|
File.write('NOTICE-ruby', result.body)
|
||||||
|
end
|
||||||
|
|
||||||
|
desc "checking whether NOTICE-ruby matches the one on ClearlyDefined.io"
|
||||||
|
task :verify do
|
||||||
|
result = get_notice_ruby
|
||||||
|
raise "NOTICE-ruby is not up to date. Run bin/rails notice:ruby:update to update the file." if result.body != File.read('NOTICE-ruby')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
namespace :js do
|
||||||
|
require 'fileutils'
|
||||||
|
def get_notice_js
|
||||||
|
raise "NOTICE-js could not be retrieved from Clearlydefined.io" unless system('yarn noticeme')
|
||||||
|
File.read('NOTICE')
|
||||||
|
end
|
||||||
|
|
||||||
|
desc "generating NOTICE-js from ClearlyDefined.io"
|
||||||
|
task :update do
|
||||||
|
if (File.exists?('NOTICE'))
|
||||||
|
File.delete('NOTICE')
|
||||||
|
end
|
||||||
|
result = get_notice_js
|
||||||
|
FileUtils.mv('NOTICE', 'NOTICE-js', force: true)
|
||||||
|
end
|
||||||
|
|
||||||
|
desc "checking whether NOTICE-js matches the one on ClearlyDefined.io"
|
||||||
|
task :verify do
|
||||||
|
result = get_notice_js
|
||||||
|
raise "NOTICE-js is not up to date. Run bin/rails notice:js:update to update the file." if result != File.read('NOTICE-js')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue