Skip to content

Commit 780bb08

Browse files
committed
upgrade GHA to use shared workflows
1 parent 6d7e0d9 commit 780bb08

File tree

9 files changed

+58
-229
lines changed

9 files changed

+58
-229
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 134 deletions
This file was deleted.

.github/workflows/docker-ci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Docker CI
2+
3+
on:
4+
push:
5+
release:
6+
workflow_dispatch:
7+
8+
jobs:
9+
build:
10+
uses: BerkeleyLibrary/.github/.github/workflows/docker-build.yml@v1.1.0
11+
12+
test:
13+
needs: build
14+
uses: BerkeleyLibrary/.github/.github/workflows/docker-test.yml@v1.1.0

.github/workflows/release.yml

Lines changed: 0 additions & 69 deletions
This file was deleted.

Dockerfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,14 @@ RUN SECRET_KEY_BASE=1 rails assets:precompile --trace
177177
ARG BUILD_TIMESTAMP
178178
ARG BUILD_URL
179179
ARG DOCKER_TAG
180-
ARG GIT_BRANCH
181-
ARG GIT_COMMIT
182-
ARG GIT_URL
180+
ARG GIT_REF_NAME
181+
ARG GIT_SHA
182+
ARG GIT_REPOSITORY_URL
183183

184184
# build arguments aren't persisted in the image, but ENV values are
185185
ENV BUILD_TIMESTAMP="${BUILD_TIMESTAMP}"
186186
ENV BUILD_URL="${BUILD_URL}"
187187
ENV DOCKER_TAG="${DOCKER_TAG}"
188-
ENV GIT_BRANCH="${GIT_BRANCH}"
189-
ENV GIT_COMMIT="${GIT_COMMIT}"
190-
ENV GIT_URL="${GIT_URL}"
188+
ENV GIT_REF_NAME="${GIT_REF_NAME}"
189+
ENV GIT_SHA="${GIT_SHA}"
190+
ENV GIT_REPOSITORY_URL="${GIT_REPOSITORY_URL}"

bin/setup

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,16 @@
11
#!/usr/bin/env ruby
2-
require 'fileutils'
2+
require "fileutils"
33

4-
# path to your application root.
5-
APP_ROOT = File.expand_path('..', __dir__)
4+
APP_ROOT = File.expand_path("..", __dir__)
65

76
def system!(*args)
87
system(*args) || abort("\n== Command #{args} failed ==")
98
end
109

1110
FileUtils.chdir APP_ROOT do
12-
# This script is a way to setup or update your development environment automatically.
13-
# This script is idempotent, so that you can run it at anytime and get an expectable outcome.
14-
# Add necessary setup steps to this file.
15-
16-
puts '== Installing dependencies =='
17-
system! 'gem install bundler --conservative'
18-
system('bundle check') || system!('bundle install')
19-
20-
# Install JavaScript dependencies
21-
# system('bin/yarn')
22-
2311
puts "\n== Removing old logs and tempfiles =="
24-
system! 'bin/rails log:clear tmp:clear'
12+
system! "bin/rails log:clear tmp:clear"
2513

2614
puts "\n== Restarting application server =="
27-
system! 'bin/rails restart'
15+
system! "bin/rails restart"
2816
end

bin/test

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env ruby
2+
require "fileutils"
3+
4+
APP_ROOT = File.expand_path("..", __dir__)
5+
6+
# Check test coverage when running rspec
7+
ENV['COVERAGE'] = '1'
8+
9+
# Test commands (to be exec'd in order)
10+
TESTS = [
11+
%w(rspec -f html --out artifacts/rspec.html),
12+
%w(rubocop -f html --out artifacts/rubocop.html),
13+
]
14+
15+
FileUtils.chdir APP_ROOT do
16+
exit TESTS.reduce(true) { |passed, test| system(*test) && passed }
17+
end

config/initializers/build_info.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class BuildInfo
99
MULTIPLE_HYPHEN_ESCAPE_RE = /((?<=-)-)|(-(?=-))/
1010
HYPHEN_ENTITY_ESCAPE = '&#45;'.freeze
1111

12-
BUILD_VARS = %w[CI BUILD_TIMESTAMP BUILD_URL DOCKER_TAG GIT_BRANCH GIT_COMMIT GIT_URL].freeze
12+
BUILD_VARS = %w[CI BUILD_TIMESTAMP BUILD_URL DOCKER_TAG GIT_REF_NAME GIT_SHA GIT_REPOSITORY_URL].freeze
1313

1414
attr_reader :info
1515

docker-compose.ci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
3+
services:
4+
app:
5+
build: !reset
6+
image: ${DOCKER_APP_IMAGE}
7+
volumes: !reset
8+
volumes:
9+
- artifacts:/opt/app/artifacts
10+
11+
volumes:
12+
artifacts:
13+

spec/initializers/build_info_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ module AvPlayer
1111
BUILD_TIMESTAMP: '2021-03-22T21:57:07+0000',
1212
BUILD_URL: 'https://jenkins.lib.berkeley.edu/job/gitlab/job/lap/job/lap%252Favplayer/job/LIT-2266-build-args/1/',
1313
DOCKER_TAG: 'containers.lib.berkeley.edu/lap/avplayer/lit-2266-build-args:build-1',
14-
GIT_BRANCH: 'LIT-2266-build-args',
15-
GIT_COMMIT: 'e2493452b7e6ebe98856fa3aff6b2c8f24063586',
16-
GIT_URL: 'git@git.lib.berkeley.edu:lap/avplayer.git'
14+
GIT_REF_NAME: 'LIT-2266-build-args',
15+
GIT_SHA: 'e2493452b7e6ebe98856fa3aff6b2c8f24063586',
16+
GIT_REPOSITORY_URL: 'git@git.lib.berkeley.edu:lap/avplayer.git'
1717
}.freeze
1818
end
1919

0 commit comments

Comments
 (0)