In this lab you will use the dry-run
command to convert a CircleCI pipeline to its equivalent GitHub Actions workflow.
- Followed the steps here to set up your Codespace environment.
- Completed the configure lab.
- Completed the audit lab.
You will be performing a dry run migration against a CircleCI project. Answer the following questions before running this command:
-
What project do you want to convert?
- circleci-demo-ruby-rails. This is one of the sample projects available in the CircleCI actions-importer-labs organization.
-
Where do you want to store the result?
- tmp/dry-run. This can be any path within the working directory that GitHub Actions Importer commands are executed from.
-
Navigate to your codespace terminal
-
Run the following command from the root directory:
gh actions-importer dry-run circle-ci --output-dir tmp/dry-run --circle-ci-project circleci-demo-ruby-rails
-
The command will list all the files written to disk when the command succeeds.
$ gh actions-importer dry-run circle-ci --output-dir tmp/dry-run --circle-ci-project circleci-demo-ruby-rails --circle-ci-organization actions-importer-labs [2022-09-19 19:46:03] Logs: 'tmp/dry-run/log/actions-importer-20220919-194603.log' [2022-09-19 19:46:05] Output file(s): [2022-09-19 19:46:05] tmp/dry-run/actions-importer-labs/circleci-demo-ruby-rails/.github/workflows/build_and_test.yml
Note: It is expected that you will see "Resource not found" warnings in the output. These warnings are present because you are not a member of the CircleCI organization actions-importer-labs.
-
View the converted workflow:
- Find
tmp/dry-run/actions-importer-labs/circleci-demo-ruby-rails/.github/workflows
in the file explorer pane in your codespace. - Click
build_and_test.yml
to open.
- Find
The files generated from the dry-run
command represent the equivalent Actions workflow for the CircleCI project. The CircleCI configuration and converted workflow can be seen below:
CircleCI configuration 👇
version: 2.1
orbs:
ruby: circleci/[email protected]
node: circleci/node@2
jobs:
build:
docker:
- image: cimg/ruby:2.7.5-node
steps:
- checkout
- ruby/install-deps
# Store bundle cache
- node/install-packages:
pkg-manager: yarn
cache-key: "yarn.lock"
test:
parallelism: 3
docker:
- image: cimg/ruby:2.7.5-node
- image: circleci/postgres:9.5-alpine
environment:
POSTGRES_USER: circleci-demo-ruby
POSTGRES_DB: rails_blog_test
POSTGRES_PASSWORD: ""
environment:
BUNDLE_JOBS: "3"
BUNDLE_RETRY: "3"
PGHOST: 127.0.0.1
PGUSER: circleci-demo-ruby
PGPASSWORD: ""
RAILS_ENV: test
steps:
- checkout
- ruby/install-deps
- node/install-packages:
pkg-manager: yarn
cache-key: "yarn.lock"
- run:
name: Wait for DB
command: dockerize -wait tcp://localhost:5432 -timeout 1m
- run:
name: Database setup
command: bundle exec rails db:schema:load --trace
# Run rspec in parallel
- ruby/rspec-test
- ruby/rubocop-check
workflows:
version: 2
build_and_test:
jobs:
- build
- test:
requires:
- build
Converted workflow 👇
name: actions-importer-labs/circleci-demo-ruby-rails/build_and_test
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
container:
image: cimg/ruby:2.7.5-node
steps:
- name: Set up bundler cache
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0.2
bundler-cache: true
- uses: actions/checkout@v2
- run: bundle check || bundle install
env:
BUNDLE_DEPLOYMENT: true
- id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- uses: actions/cache@v2
with:
path: "${{ steps.yarn-cache-dir-path.outputs.dir }}"
key: "${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}"
restore-keys: "${{ runner.os }}-yarn-"
- run: yarn install --frozen-lockfile
test:
runs-on: ubuntu-latest
container:
image: cimg/ruby:2.7.5-node
services:
postgres:
image: postgres:9.5-alpine
env:
POSTGRES_USER: circleci-demo-ruby
POSTGRES_DB: rails_blog_test
POSTGRES_PASSWORD: ''
needs:
- build
env:
BUNDLE_JOBS: '3'
BUNDLE_RETRY: '3'
PGHOST: 127.0.0.1
PGUSER: circleci-demo-ruby
PGPASSWORD: ''
RAILS_ENV: test
steps:
- name: Set up bundler cache
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0.2
bundler-cache: true
- uses: actions/checkout@v2
- run: bundle check || bundle install
env:
BUNDLE_DEPLOYMENT: true
- id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- uses: actions/cache@v2
with:
path: "${{ steps.yarn-cache-dir-path.outputs.dir }}"
key: "${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}"
restore-keys: "${{ runner.os }}-yarn-"
- run: yarn install --frozen-lockfile
- name: Wait for DB
run: dockerize -wait tcp://localhost:5432 -timeout 1m
- name: Database setup
run: bundle exec rails db:schema:load --trace
- run: bundle exec rspec spec --profile 10 --format RspecJunitFormatter --out /tmp/test-results/rspec/results.xml --format progress
- run: bundle exec rubocop --format progress
Despite these two pipelines using different syntax they will function equivalently.
Use custom transformers to customize GitHub Actions Importer's behavior