Skip to content

Commit

Permalink
Merge pull request #12 from dgodongm/dg_parallel_ci
Browse files Browse the repository at this point in the history
run tests in parallel across 3 machines
  • Loading branch information
dgodongm authored Mar 25, 2024
2 parents 4f5b766 + c5984df commit c1ae58a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
20 changes: 13 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,29 @@ name: Run API tests
on: push
jobs:
cypress-run:
runs-on: ubuntu-22.04
# Cypress Docker image from https://hub.docker.com/r/cypress
# with browsers pre-installed
container:
image: cypress/browsers:latest
options: --user 1001
runs-on: macos-latest
strategy:
# when one test fails, DO NOT cancel the other
# containers, because this will kill Cypress processes
# leaving Cypress Cloud hanging ...
# https://github.com/cypress-io/github-action/issues/48
fail-fast: false
matrix:
# run 3 copies of the current job in parallel
containers: [1, 2, 3]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cypress run
uses: cypress-io/github-action@v6
with:
browser: chrome
record: true
parallel: true
group: "Chrome"
start: npm start
# quote the url to be safe against YML parsing surprises
wait-on: "http://localhost:3001"
record: true
env:
# pass GitHub token to allow accurately detecting a build vs a re-run build
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
20 changes: 9 additions & 11 deletions cypress/e2e/get_bookings.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,12 @@ import bookings_helpers from "../utils/bookings_helpers";
describe("Get Bookings spec", () => {
const sampleFName = bookings_generator.generate_firstname();
const sampleLName = bookings_generator.generate_lastname();
const sampleCheckin = new Date();
let sampleCheckinStr =
bookings_helpers.convertToBookingDateString(sampleCheckin);
const sampleCheckout = new Date();
let sampleCheckoutStr =
bookings_helpers.convertToBookingDateString(sampleCheckout);
let newbooking;

before(() => {
let newbooking = bookings_generator.generate_booking();
newbooking = bookings_generator.generate_booking();
newbooking.firstname = sampleFName;
newbooking.lastname = sampleLName;
newbooking.bookingdates.checkin = sampleCheckinStr;
newbooking.bookingdates.checkout = sampleCheckoutStr;
bookings_wrapper.create_booking(newbooking);
});

Expand Down Expand Up @@ -56,8 +49,13 @@ describe("Get Bookings spec", () => {
});

it("Get Booking by Checkin", () => {
// workaround for fact that restful booker saves dates off by one
let checkinMinus1 = new Date(newbooking.bookingdates.checkin);
checkinMinus1.setDate(checkinMinus1.getDate() - 1);
let checkinMinus1Str =
bookings_helpers.convertToBookingDateString(checkinMinus1);
bookings_wrapper
.get_booking_by({ checkin: sampleCheckinStr })
.get_booking_by({ checkin: checkinMinus1Str })
.then((response) => {
expect(response.status).to.be.equal(200);
expect(response.body).to.have.lengthOf.above(0);
Expand All @@ -66,7 +64,7 @@ describe("Get Bookings spec", () => {

it("Get Booking by Checkout", () => {
bookings_wrapper
.get_booking_by({ checkout: sampleCheckoutStr })
.get_booking_by({ checkout: newbooking.bookingdates.checkout })
.then((response) => {
expect(response.status).to.be.equal(200);
expect(response.body).to.have.lengthOf.above(0);
Expand Down

0 comments on commit c1ae58a

Please sign in to comment.