Skip to content

Commit

Permalink
Fixed gem testing, building and release on SemaphoreCI
Browse files Browse the repository at this point in the history
  • Loading branch information
vovimayhem committed Feb 16, 2020
1 parent fd80095 commit 6429dc5
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 155 deletions.
69 changes: 25 additions & 44 deletions .semaphore/publishing.yml
Original file line number Diff line number Diff line change
@@ -1,62 +1,43 @@
version: v1.0

name: 'Publishing Pipeline'
name: Publishing

agent:
machine:
type: e1-standard-2
os_image: ubuntu1804

blocks:
- name: Publish to Rubygems
task:
secrets:
- name: AWS
- name: ICALIA_RUBYGEMS
prologue:
commands:
- checkout
global_job_config:
secrets:
- name: icalia-labs-semaphore-registry
- name: ICALIA_RUBYGEMS
prologue:
commands:
- checkout

# Correct the permissions on rubygems credentials:
- chmod 0600 /home/semaphore/.gem/credentials
# Correct the permissions on rubygems credentials:
- chmod 0600 /home/semaphore/.gem/credentials

# Add the scripts for CI to the PATH:
- export PATH=$(pwd)/.semaphore/bin:${PATH}
# Add the scripts for CI to the PATH:
- export PATH=$(pwd)/.semaphore/bin:${PATH}

# Generate the dotenv file:
- generate-dotenv-file > .env
# Generate the dotenv file:
- generate-dotenv-file > .env

# Alias docker-compose commands as 'ci-compose':
- alias ci-compose="docker-compose --file docker-compose.yml --file ci-compose.yml"
# Alias docker-compose commands as 'ci-compose':
- alias ci-compose="docker-compose --file docker-compose.yml --file ci-compose.yml"

# Log in to AWS ECR:
- $(aws ecr get-login --no-include-email --region eu-central-1)
# Log in to Semaphore CI Docker Registry:
- docker login -u "$SEMAPHORE_REGISTRY_USERNAME" -p "$SEMAPHORE_REGISTRY_PASSWORD" https://icalia-labs.registry-beta.semaphoreci.com

# Pull the images referenced in the 'cache_from' key:
- docker-image-manager download-cache libraries
# Pull the images referenced in the 'cache_from' key:
- docker-image-manager download-cache test

blocks:
- name: Publish to Rubygems
task:
jobs:
- name: Event Core
commands:
# Build & publish the gem
- ci-compose run event_core rake release

- name: Event Notification
commands:
# Build & publish the gem
- ci-compose run event_notification rake release

- name: Event Webhook
commands:
# Build & publish the gem
- ci-compose run event_webhook rake release

- name: Event Meta
commands:
# Build & publish the gem
- ci-compose run event_meta rake release

- name: SDK Meta
- name: Publish omniauth-gem
commands:
# Build & publish the gem
- ci-compose run sdk_meta rake release
- ci-compose run test rake release
111 changes: 30 additions & 81 deletions .semaphore/semaphore.yml
Original file line number Diff line number Diff line change
@@ -1,106 +1,55 @@
version: v1.0

name: 'Main Pipeline'
name: 'Test & Build'

agent:
machine:
type: e1-standard-2
os_image: ubuntu1804

blocks:
- name: Build Test Image
task:
secrets:
- name: AWS
prologue:
commands:
- checkout
auto_cancel:
running:
when: "branch != 'master'"

global_job_config:
secrets:
- name: icalia-labs-semaphore-registry
prologue:
commands:
# Checkout the code:
- checkout

# Add the scripts for CI to the PATH:
- export PATH=$(pwd)/.semaphore/bin:${PATH}
# Add the scripts for CI to the PATH:
- export PATH=$(pwd)/.semaphore/bin:${PATH}

# Generate the dotenv file:
- generate-dotenv-file > .env
# Generate the dotenv file:
- generate-dotenv-file > .env

# Alias docker-compose commands as 'ci-compose':
- alias ci-compose="docker-compose --file docker-compose.yml --file ci-compose.yml"
# Alias docker-compose commands as 'ci-compose':
- alias ci-compose="docker-compose --file docker-compose.yml --file ci-compose.yml"

# Log in to AWS ECR:
- $(aws ecr get-login --no-include-email --region eu-central-1)
# Log in to Semaphore CI Docker Registry:
- docker login -u "$SEMAPHORE_REGISTRY_USERNAME" -p "$SEMAPHORE_REGISTRY_PASSWORD" https://icalia-labs.registry-beta.semaphoreci.com

blocks:
- name: Run Tests
task:
jobs:
- name: Build
- name: Testing
commands:
# Pull the images referenced in the 'cache_from' key:
- docker-image-manager download-cache libraries
- docker-image-manager download-cache test

# Build the test image:
- ci-compose build --pull libraries
- ci-compose build --pull test

# Tag & Push test image so we can use it on image cache:
- docker-image-manager tag-and-push libraries

- name: SDK Tests
task:
secrets:
- name: AWS
prologue:
commands:
- checkout

# Add the scripts for CI to the PATH:
- export PATH=$(pwd)/.semaphore/bin:${PATH}

# Generate the dotenv file:
- generate-dotenv-file > .env

# Alias docker-compose commands as 'ci-compose':
- alias ci-compose="docker-compose --file docker-compose.yml --file ci-compose.yml"

# Log in to AWS ECR:
- $(aws ecr get-login --no-include-email --region eu-central-1)

# Pull the images referenced in the 'cache_from' key:
- docker-image-manager download-cache libraries
jobs:
- name: Event Core
commands:
# Run the tests
- ci-compose run event_core rake spec

# Build the gem
- ci-compose run event_core gem build icalia-sdk-event-core

- name: Event Notification
commands:
# Run the tests
- ci-compose run event_notification rake spec

# Build the gem
- ci-compose run event_notification gem build icalia-sdk-event-notification

- name: Event Webhook
commands:
# Run the tests
- ci-compose run event_webhook rake spec

# Build the gem
- ci-compose run event_webhook gem build icalia-sdk-event-webhook

- name: Event Meta
commands:
# Run the tests
- ci-compose run event_meta rake spec
- docker-image-manager tag-and-push test

# Build the gem
- ci-compose run event_meta gem build icalia-sdk-event

- name: SDK Meta
commands:
# Run the tests
- ci-compose run sdk_meta rake spec
- ci-compose run test rake spec

# Build the gem
- ci-compose run sdk_meta gem build icalia-sdk
- ci-compose run test gem build omniauth-icalia

promotions:
- name: Publish
Expand Down
39 changes: 9 additions & 30 deletions ci-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,18 @@
version: '3.7'

services:
libraries: &library
image: 564922552600.dkr.ecr.eu-central-1.amazonaws.com/icalia-sdk-ruby:testing-${GIT_SHORT_SHA:-latest}
test:
image: icalia-labs.registry-beta.semaphoreci.com/icalialabs/omniauth-icalia:testing-${GIT_COMMIT_SHORT_SHA:-latest}
build:
target: testing
context: .
cache_from:
# Since docker-compose will try to build the unused (at this time) runtime
# stage, and this project's dev stages and runtime stages start from
# different images, we need to include the releaseable image here as well
# - this may change with Docker 19.x:
- 564922552600.dkr.ecr.eu-central-1.amazonaws.com/icalia-sdk-ruby:testing-${GIT_SHORT_SHA:-latest}
- 564922552600.dkr.ecr.eu-central-1.amazonaws.com/icalia-sdk-ruby:testing-${TAG_SAFE_BRANCH}
- 564922552600.dkr.ecr.eu-central-1.amazonaws.com/icalia-sdk-ruby:testing
command: bundle exec rake spec
# Since docker-compose will try to build the unused (at this time)
# runtime stage, and this project's dev stages and runtime stages start
# from different images, we need to include the releaseable image here
# as well - this may change with Docker 19.x:
- icalia-labs.registry-beta.semaphoreci.com/icalialabs/omniauth-icalia:testing-${GIT_COMMIT_SHORT_SHA:-latest}
- icalia-labs.registry-beta.semaphoreci.com/icalialabs/omniauth-icalia:testing-${TAG_SAFE_BRANCH}
- icalia-labs.registry-beta.semaphoreci.com/icalialabs/omniauth-icalia:testing
volumes:
- ${HOME}/.gem/credentials:/root/.gem/credentials

event_core:
<<: *library
working_dir: /usr/src/gems/icalia-sdk-event-core

event_notification:
<<: *library
working_dir: /usr/src/gems/icalia-sdk-event-notification

event_webhook:
<<: *library
working_dir: /usr/src/gems/icalia-sdk-event-webhook

event_meta:
<<: *library
working_dir: /usr/src/gems/icalia-sdk-event

sdk_meta:
<<: *library
working_dir: /usr/src/gems/icalia-sdk

0 comments on commit 6429dc5

Please sign in to comment.