Oral  Brekke

Oral Brekke

1622549400

Caching Ruby Gems on Github Actions Using ruby/setup-ruby or actions/cache

How do you cache Ruby gems on Github Actions CI? There are actually 2 ways of doing it with ruby/setup-ruby or actions/cache.

How to start CI build faster by loading Ruby gems from cache on Github Actions? You can start running your tests for a Ruby on Rails project quicker if you manage to set up all dependencies in a short amount of time. Caching can be helpful with that. Ruby gems needed for your project can be cached by Github Actions and thanks to that they can be loaded much faster when you run a new CI build.

You will learn how to configure Github Actions using:

  • actions/cache — it’s a popular solution to cache Ruby gems.
  • ruby/setup-ruby — it’s a solution to install a specific Ruby version and cache Ruby gems with bundler. Two features in one action.

Actions/cache — Just Cache Dependencies

Actions/cache is a popular solution that can be used to save data into the cache and restore it during the next CI build. It’s often used for Ruby on Rails projects that also use actions/setup-ruby for managing the Ruby version on Github Actions.

Let’s look at the Github Actions caching config example using actions/cache.

## .github/workflows/main.yml
name: Main
on: [push, pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - uses: actions/cache@v2
        with:
          path: vendor/bundle
          key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
          restore-keys: |
            ${{ runner.os }}-gems-

      - name: Bundle install
        env:
          RAILS_ENV: test
        run: |
          bundle config path vendor/bundle
          bundle install --jobs 4 --retry 3

#ruby #testing #tech #github #ruby on rails #cache #tests

What is GEEK

Buddha Community

Caching Ruby Gems on Github Actions Using ruby/setup-ruby or actions/cache
Oral  Brekke

Oral Brekke

1622549400

Caching Ruby Gems on Github Actions Using ruby/setup-ruby or actions/cache

How do you cache Ruby gems on Github Actions CI? There are actually 2 ways of doing it with ruby/setup-ruby or actions/cache.

How to start CI build faster by loading Ruby gems from cache on Github Actions? You can start running your tests for a Ruby on Rails project quicker if you manage to set up all dependencies in a short amount of time. Caching can be helpful with that. Ruby gems needed for your project can be cached by Github Actions and thanks to that they can be loaded much faster when you run a new CI build.

You will learn how to configure Github Actions using:

  • actions/cache — it’s a popular solution to cache Ruby gems.
  • ruby/setup-ruby — it’s a solution to install a specific Ruby version and cache Ruby gems with bundler. Two features in one action.

Actions/cache — Just Cache Dependencies

Actions/cache is a popular solution that can be used to save data into the cache and restore it during the next CI build. It’s often used for Ruby on Rails projects that also use actions/setup-ruby for managing the Ruby version on Github Actions.

Let’s look at the Github Actions caching config example using actions/cache.

## .github/workflows/main.yml
name: Main
on: [push, pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - uses: actions/cache@v2
        with:
          path: vendor/bundle
          key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
          restore-keys: |
            ${{ runner.os }}-gems-

      - name: Bundle install
        env:
          RAILS_ENV: test
        run: |
          bundle config path vendor/bundle
          bundle install --jobs 4 --retry 3

#ruby #testing #tech #github #ruby on rails #cache #tests

Oral  Brekke

Oral Brekke

1617973680

Setup Ruby on Github Actions to cache Ruby gems for Rails project

How to start CI build faster by loading Ruby gems from cache on Github Actions? You can start running your tests for a Ruby on Rails project quicker if you manage to set up all dependencies in a short amount of time. Caching can be helpful with that. Ruby gems needed for your project can be cached by Github Actions and thanks to that they can be loaded much faster when you run a new CI build.

You will learn how to configure Github Actions using:

  • actions/cache — it’s a popular solution to cache Ruby gems.
  • ruby/setup-ruby — it’s a solution to install a specific Ruby version and cache Ruby gems with bundler. Two features in one action.

actions/cache — just cache dependencies

Actions/cache is a popular solution that can be used to save data into the cache and restore it during the next CI build. It’s often used for Ruby on Rails projects that also use actions/setup-ruby for managing the Ruby version on Github Actions.

#github-actions #ruby #github #tech

Github Actions auto split of slow RSpec test file in parallel jobs for Ruby, Rails project

Splitting your CI build jobs between multiple machines running in parallel is a great way to make the process fast, which results in more time for building features. Github Actions allows running parallel jobs easily. In a previous article, we explained how you can use  Knapsack Pro to  split your RSpec test files efficiently between parallel jobs on GitHub Actions. Today we’d like to show how to address the problem of slow test files negatively impacting the whole build times.

Consider the split

Imagine you have a project with 30 RSpec spec files. Each file contains multiple test examples (RSpec “

its”). Most of the files are fairly robust, fast unit tests. Let’s say there are also some slower files, like feature specs. Perhaps one such feature spec file takes approximately 5 minutes to execute.

When we run different spec files on different parallel machines, we strive for similar execution time on all of them. In a described scenario, even if we run 30 parallel jobs (each one running just one test file), the 5 minute feature spec would be a bottleneck of the whole build. 29 machines may finish their work in a matter of seconds, but the whole build won’t be complete until the 1 remaining node finishes executing its file.

#github #github-actions #rspec #ruby #ruby-on-rails #test-automation #devops #good-company

Desmond  Gerber

Desmond Gerber

1624347085

How to Create a Custom GitHub Actions Using JavaScript — Beginner Level

In this blog, we are going to learn how to create our own custom GitHub action using javaScript.

Prerequisite

  • Basic JavaScript Knowledge
  • Basic Git & GitHub Knowledge

About GitHub Actions

Automate, customize, and execute your software development workflows right in your repository with GitHub Actions. You can discover, create, and share actions to perform any job you’d like, including CI/CD, and combine actions in a completely customized workflow.

Types of Actions

There are three types of actions: Docker container actions, JavaScript actions, and composite run steps actions.

JavaScript Custom Action

Let’s create a Custom GitHub Action using JavaScript by creating a public repo, once the repo is created, we can clone it to our local machine using VS Code or GitPod. You need to have Node.js 12.x or higher and npm installed on your machine to perform the steps described here. You can verify the node and npm versions with the following commands in a VS Code or GitPod terminal.

node --version 
npm --version

#github #github-tutorial #github-actions #github-trend

Oral  Brekke

Oral Brekke

1617437520

Deploying my portfolio website on Github Pages using Github Actions.

I recently deployed  my portfolio site and wanted to try out github actions and this is my experience of automating the deployment.

This article is more focused on how you can use the GitHub actions and how easy it is to deploy your code to GitHub pages rather than the portfolio site code.So every time you make an update or build to your website ,the changes are automatically reflected and this automated deploying process makes work much faster.

The way GitHub action works is you create actions in your repositories by creating one or more yaml files and these are called workflows.Workflows now can handle build tasks like CI CD. This means you use the action to test your code and push the site to the desired hosting platform (in this case GitHub pages ) when the main branch changes .

First step assuming that you have a GitHub account is to create a repository having your website code in it.Now I have a bootstrap website but in the future I do plan on adding node JS so I already added package.json.

#workflow #portfolio #github #github-actions #github-pages