Skip to content

Commit

Permalink
Add github actions and gitignore file
Browse files Browse the repository at this point in the history
  • Loading branch information
aguspe committed Sep 14, 2023
1 parent ae6df38 commit 75f89a9
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/generators/actions/actions_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

require_relative '../generator'

class ActionsGenerator < Generator
def generate_actions_file
return unless web?

template('templates/actions.tt', "#{name}/.github/workflows/test_pipeline.yml")
end
end
64 changes: 64 additions & 0 deletions lib/generators/actions/templates/actions.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: <%- if framework == 'cucumber' -%>Cucumber Tests<%- else -%>Rspec Tests<%- end -%>

on:
workflow_dispatch:
inputs:
browser:
type: choice
description: Which browser to test
required: true
options:
- chrome

jobs:
build:
name: CI
runs-on: ubuntu-latest

steps:
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1.0
bundler-cache: true

- name: Checkout repository
uses: actions/checkout@v3

- name: Install gems
run: bundle install

- name: Create allure-results folder
run: mkdir -p allure-results

- name: Create screenshots folder
run: mkdir -p allure-results/screenshots

- name: Build and test with rspec
run: <%- if framework == 'cucumber' -%>cucumber features --format pretty <%- else -%>bundle exec rspec spec --format documentation<%- end -%>

- name: Get Allure history
uses: actions/checkout@v2
if: always()
continue-on-error: true
with:
ref: gh-pages
path: gh-pages

- name: Allure Report
uses: simple-elf/allure-report-action@master
if: always()
id: allure-report
with:
allure_results: allure-results
gh_pages: gh-pages
allure_report: allure-report
allure_history: allure-history

- name: Deploy report to Github Pages
if: always()
uses: peaceiris/actions-gh-pages@v2
env:
PERSONAL_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PUBLISH_BRANCH: gh-pages
PUBLISH_DIR: allure-history
4 changes: 4 additions & 0 deletions lib/generators/common_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ def generate_rubocop_file
template('common/rubocop.tt', "#{name}/.rubocop.yml")
end

def generate_gitignore_file
template('common/git_ignore.tt', "#{name}/.gitignore")
end

def create_allure_folder
empty_directory "#{name}/allure-results"
end
Expand Down
1 change: 1 addition & 0 deletions lib/generators/templates/common/git_ignore.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
allure-results

0 comments on commit 75f89a9

Please sign in to comment.