From 500d85465e397dac89a14f81aa514f9745b40a41 Mon Sep 17 00:00:00 2001 From: Begona Guereca Date: Wed, 14 Sep 2022 10:55:52 -0700 Subject: [PATCH 1/2] Create 3-dry-run.md --- travis/3-dry-run.md | 189 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 189 insertions(+) create mode 100644 travis/3-dry-run.md diff --git a/travis/3-dry-run.md b/travis/3-dry-run.md new file mode 100644 index 0000000..662ecc6 --- /dev/null +++ b/travis/3-dry-run.md @@ -0,0 +1,189 @@ +# Perform a dry-run of a CircleCI pipeline + +In this lab you will use the `dry-run` command to convert a CircleCI pipeline to its equivalent GitHub Actions workflow. + +## Prerequisites + +1. Followed the steps [here](./readme.md#configure-your-codespace) to set up your Codespace environment. +2. Completed the [configure lab](./1-configure.md#configuring-credentials). +3. Completed the [audit lab](./2-audit.md). + +## Perform a dry run + +You will be performing a dry-run against a CircleCI project. Answer the following questions before running this command: + +1. What project do you want to convert? + - __circleci-demo-ruby-rails__. This is one of the sample projects avaiable in the CircleCI labs-data organization. + +2. Where do you want to store the result? + - __./tmp/dry-run-lab__. This can be any path within the working directory that Valet commands are executed from. + +### Steps + +1. Navigate to your codespace terminal +2. Run the following command from the root directory: + + ```bash + gh valet dry-run circle-ci --output-dir ./tmp/dry-run-lab --circle-ci-project circleci-demo-ruby-rails + ``` + +3. The command will list all the files written to disk when the command succeeds. + + ![command-result](https://user-images.githubusercontent.com/18723510/189911131-bf6bfd6f-2b5e-4e49-8d14-95ef9c312117.png) + + + +4. View the converted workflow: + - Find `./tmp/dry-run-lab/labs-data/circleci-demo-ruby-rails` in the file explorer pane in your codespace. + - Click `build_and_test.yml` to open. + +## Inspect the output files + +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 👇 + +```yaml +version: 2.1 +orbs: + ruby: circleci/ruby@1.1.0 + 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 👇 + +```yaml +name: labs-data/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. + +## Next lab + +[Use custom transformers to customize Valet's behavior](./4-custom-transformers.md) From 670b62c3ea0159590d07078e405993d050a393f8 Mon Sep 17 00:00:00 2001 From: Begona Guereca Date: Wed, 14 Sep 2022 14:01:38 -0700 Subject: [PATCH 2/2] Travis Dry-run lab --- travis/3-dry-run.md | 211 +++++++++++++++----------------------------- 1 file changed, 71 insertions(+), 140 deletions(-) diff --git a/travis/3-dry-run.md b/travis/3-dry-run.md index 662ecc6..f0a3d87 100644 --- a/travis/3-dry-run.md +++ b/travis/3-dry-run.md @@ -1,6 +1,6 @@ -# Perform a dry-run of a CircleCI pipeline +# Perform a dry-run of a TravisCI pipeline -In this lab you will use the `dry-run` command to convert a CircleCI pipeline to its equivalent GitHub Actions workflow. +In this lab you will use the `dry-run` command to convert a TravisCI pipeline to its equivalent GitHub Actions workflow. ## Prerequisites @@ -10,95 +10,56 @@ In this lab you will use the `dry-run` command to convert a CircleCI pipeline to ## Perform a dry run -You will be performing a dry-run against a CircleCI project. Answer the following questions before running this command: +You will be performing a dry-run against a TravisCI project. Answer the following questions before running this command: -1. What project do you want to convert? - - __circleci-demo-ruby-rails__. This is one of the sample projects avaiable in the CircleCI labs-data organization. +1. What pipeline do you want to convert? + - __ruby-example__. This is one of the sample projects avaiable in the TravisCI labs-data organization. 2. Where do you want to store the result? - __./tmp/dry-run-lab__. This can be any path within the working directory that Valet commands are executed from. ### Steps -1. Navigate to your codespace terminal +1. Navigate to your codespace terminal. 2. Run the following command from the root directory: ```bash - gh valet dry-run circle-ci --output-dir ./tmp/dry-run-lab --circle-ci-project circleci-demo-ruby-rails + gh valet dry-run travis-ci --travis-ci-repository "ruby-example" --output-dir tmp/travis/dry-run-lab ``` 3. The command will list all the files written to disk when the command succeeds. - ![command-result](https://user-images.githubusercontent.com/18723510/189911131-bf6bfd6f-2b5e-4e49-8d14-95ef9c312117.png) - - + ![command-result](https://user-images.githubusercontent.com/19557880/190260513-87bae04f-2ff2-4539-b4e5-1e68eba3cf2c.png) 4. View the converted workflow: - - Find `./tmp/dry-run-lab/labs-data/circleci-demo-ruby-rails` in the file explorer pane in your codespace. - - Click `build_and_test.yml` to open. + - Find `./tmp/travis/dry-run-lab` in the file explorer pane in your codespace. + - Click `ruby-example.yml` to open. ## Inspect the output files -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: +The files generated from the `dry-run` command represent the equivalent Actions workflow for the TravisCI project. The TravisCI configuration and converted workflow can be seen below:
- CircleCI configuration 👇 + TravisCI configuration 👇 ```yaml -version: 2.1 -orbs: - ruby: circleci/ruby@1.1.0 - 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 + language: ruby + sudo: false + dist: trusty + rvm: + - 1.9.3 + - 2.0.0 + - 2.1.0 + + install: + - gem install bundler + + script: + - echo "hello!" + + jobs: + include: + - script: echo "child" ```
@@ -107,79 +68,49 @@ workflows: Converted workflow 👇 ```yaml -name: labs-data/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 + name: valet-travis-labs/ruby-example + on: + push: + branches: + - "**/*" + pull_request: + concurrency: + # # This item has no matching transformer + # maximum_number_of_builds: 0 + jobs: + test: + runs-on: # this agent type is not supported: [[{"dist"=>"trusty"}]] + ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: "${{ matrix.rvm }}" + # # 'sudo' was not transformed because there is no suitable equivalent in GitHub Actions + - run: gem install bundler + - run: echo "hello!" + strategy: + matrix: + rvm: + - 1.9.3 + - 2.0.0 + - 2.1.0 + test_2: + runs-on: # this agent type is not supported: [[{"dist"=>"trusty"}]] + ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 1.9.3 + # # 'sudo' was not transformed because there is no suitable equivalent in GitHub Actions + - run: gem install bundler + - run: echo "child" + ``` + Despite these two pipelines using different syntax they will function equivalently.