Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .rwx/sample-run.yml → .rwx/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ on:
cli:
init:
commit-sha: ${{ event.git.sha }}
github:
push:
init:
commit-sha: ${{ event.git.sha }}

base:
image: ubuntu:24.04
Expand All @@ -21,8 +25,6 @@ tasks:

- key: node-modules
use: [code, node]
agent:
tmpfs: true
Comment on lines -24 to -25
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we keep this? We generally recommend using it with node-modules

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's always going to be intuitive to end users why it's there. Despite the fact that we generally recommend it, I think we need to gradually introduce users to concepts, so I don't think it should be in the quickstart guide.

run: npm install
filter:
- package.json
Expand All @@ -35,7 +37,7 @@ tasks:
filter:
- docker-compose.yml

- key: example-tests
- key: test
use: [node-modules, docker-images]
docker: true
background-processes:
Expand All @@ -47,7 +49,7 @@ tasks:
test-results:
- path: test-results.json

- key: example-lint-failures
- key: lint
use: node-modules
run: npm run lint
outputs:
Expand Down
13 changes: 0 additions & 13 deletions Dockerfile

This file was deleted.

14 changes: 4 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@

[RWX](https://rwx.com) is the CI/CD platform for high velocity teams.

### What You'll See in CI Runs

- **Test Failures**: Some tests are intentionally designed to fail to demonstrate test result reporting
- **Linting Errors**: The source code contains various ESLint violations (missing semicolons, unused variables, etc.)
- **Debugging**: A task that demonstrates RWX's debugging capabilities

## Step 1: Install the CLI

With RWX, you can run tasks without having to push to a git repository.
Expand Down Expand Up @@ -50,16 +44,16 @@ rwx whoami

## Step 3: Kick off your first run

This repository contains a real Node.js project with intentional issues. Clone this repository and run the sample-run.yml workflow. Or if you'd prefer, check out the [documentation](https://www.rwx.com/docs/mint/guides/ci) to learn how to write your own workflows.
This repository contains an example Node.js project. Clone this repository and run the ci.yml workflow. Or if you'd prefer, check out the [documentation](https://www.rwx.com/docs/mint/guides/ci) to learn how to write your own workflows.

```
git clone git@github.com:rwx-cloud/ci-examples.git
git clone https://github.com/rwx-cloud/ci-examples.git
```
```
cd ci-examples
```
```
rwx run -f .rwx/sample-run.yml --title "Sample Run" --open
rwx run .rwx/ci.yml --open
```

You can run this example run multiple times, and you'll see that, on subsequent runs, some redundant tasks are cached.
You can run this example run multiple times and you'll see that on subsequent runs all of the tasks will be cache hits.
9 changes: 0 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,6 @@ services:
timeout: 5s
retries: 5

adminer:
image: adminer:4.8.1
ports:
- "8080:8080"
depends_on:
- db
environment:
- ADMINER_DEFAULT_SERVER=db

volumes:
postgres_data:
redis_data:
36 changes: 17 additions & 19 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
const _ = require('lodash');
// Calculate total price of items
function calculateTotal (items) {
let total = 0;

// This function has some intentional linting issues for demonstration
function calculateTotal(items) {
let total = 0

const taxRate = 0.08

for (let i = 0; i < items.length; i++) {
var item = items[i]
total += item.price * item.quantity
const item = items[i];
total += item.price * item.quantity;
}
return total

return total;
}

// Function with logic error (will cause test failure when b is 0)
function divide(a, b) {
return a / b
function divide (a, b) {
if (b === 0) {
return 0;
}
return a / b;
}

function add(a, b) {
return a + b
function add (a, b) {
return a + b;
}

function multiply( a,b ){
return a*b
function multiply (a, b) {
return a * b;
}

module.exports = {
calculateTotal,
divide,
add,
multiply
}
};
27 changes: 14 additions & 13 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
function formatCurrency(amount) {
if (amount == null) {
return '$0.00'
function formatCurrency (amount) {
if (amount === null || amount === undefined) {
return '$0.00';
}
return `$${amount.toFixed(2)},`

return `$${amount.toFixed(2)},`;
}

function validateEmail(email) {
function validateEmail (email) {
if (email && email.includes('@')) {
return true
return true;
}
return undefined;
}

function debugLog(message) {
console.log('DEBUG:', message)
function debugLog (message) {
// eslint-disable-next-line no-console
console.log('DEBUG:', message);
}

function isEven(number) {
// This logic is intentionally wrong - it returns true for odd numbers
return number % 2 === 1
function isEven (number) {
return number % 2 === 0;
}

module.exports = {
formatCurrency,
validateEmail,
debugLog,
isEven
}
};
4 changes: 1 addition & 3 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,12 @@ describe('Index functions', () => {
expect(divide(10, 2)).toBe(5);
});

// This test will fail because we're not handling division by zero
test('should handle division by zero', () => {
expect(divide(10, 0)).toBe(0);
});

// This test will also fail due to the logic error
test('should divide negative numbers', () => {
expect(divide(-10, 2)).toBe(5);
expect(divide(-10, 2)).toBe(-5);
});
});
});
10 changes: 5 additions & 5 deletions test/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ describe('Utils functions', () => {

describe('isEven', () => {
test('should identify even numbers', () => {
expect(isEven(2)).toBe(true); // This will fail - our function is wrong
expect(isEven(4)).toBe(true); // This will fail - our function is wrong
expect(isEven(2)).toBe(true);
expect(isEven(4)).toBe(true);
});

test('should identify odd numbers', () => {
expect(isEven(1)).toBe(false); // This will fail - our function is wrong
expect(isEven(3)).toBe(false); // This will fail - our function is wrong
expect(isEven(1)).toBe(false);
expect(isEven(3)).toBe(false);
});

test('should handle zero', () => {
expect(isEven(0)).toBe(true); // This will fail - 0 is even but our function is wrong
expect(isEven(0)).toBe(true);
});
});

Expand Down