Skip to content

Commit

Permalink
fix: some typos here and there (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
mandarini authored Nov 17, 2023
1 parent 0da7554 commit cc72bab
Show file tree
Hide file tree
Showing 14 changed files with 156 additions and 162 deletions.
2 changes: 1 addition & 1 deletion docs/lab10/LAB.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Let's explore some more Nx plugins by generating and running a storybook configu

4. Start typing in different titles and see how they appear in the header

<img src="../assets/storybook.gif" width="300" alt="the header component running in storybook">
<img src="../assets/storybook.gif" width="300" alt="the header component running in storybook">

<br/>

Expand Down
4 changes: 4 additions & 0 deletions docs/lab11/LAB.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ The storybook generator we invoked earlier also generated some tests. Let's try
<details>
<summary>🐳 Hint</summary>
```ts

args: {
title: 'Welcome to Board Game Hoard';
}

```
</details>

Expand All @@ -34,7 +36,9 @@ The storybook generator we invoked earlier also generated some tests. Let's try
<details>
<summary>🐳 Hint</summary>
```ts

expect(canvas.getByText(/Welcome to Board Game Hoard/gi)).toBeTruthy();

```
</details>

Expand Down
6 changes: 2 additions & 4 deletions docs/lab12/LAB.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,9 @@
10. **Run linting** again and check if all the errors went away.
💡&nbsp;&nbsp;Pass the suggested `--only-failed` option, so it doesn't relint everything.
💡&nbsp;&nbsp;Pass the suggested `--only-failed` option, so it doesn't relint everything.
<br />
11. **Commit everything** before moving on to the next lab
11. **Commit everything** before moving on to the next lab
<br />
---
Expand Down
172 changes: 84 additions & 88 deletions docs/lab15/LAB.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,57 +16,55 @@ pushed to your GitHub repo.
1. Let's make sure the master branch is up to date (it's important your latest changes are on `main` for the follow-up steps): - If you already are on `main` - commit everything:
`git add . && git commit -m "finished lab 14" git push origin master`

> If you are on a different branch, commit everything, switch to master
> If you are on a different branch, commit everything, switch to master and bring it up to date:
and bring it up to date:

```shell
git add . && git commit "finish lab 14"
git checkout master
git merge previous-branch-you-were-on
git push origin master
```
```shell
git add . && git commit "finish lab 14"
git checkout master
git merge previous-branch-you-were-on
git push origin master
```

<br />

2. Create a new file `.github/workflows/ci.yml`

```yml
name: Run CI checks # The name will show up on the GitHub Actions dashboard

on: [pull_request] # This workflow will run only on Pull Requests

jobs:
test-store: # give our job an ID
runs-on: ubuntu-latest # the image our job will run on
name: Test Store # the name that will appear on the Actions UI
steps: # what steps it will perform
- uses: actions/checkout@v4 # checkout whatever branch the PR is using
- uses: bahmutov/[email protected] # trigger an `npm install`
- run: npm run nx test store # test the "store" project
test-api:
runs-on: ubuntu-latest
name: Test API
steps:
- uses: actions/checkout@v4
- uses: bahmutov/[email protected]
- run: npm run nx test api
```
```yml
name: Run CI checks # The name will show up on the GitHub Actions dashboard
on: [pull_request] # This workflow will run only on Pull Requests
jobs:
test-store: # give our job an ID
runs-on: ubuntu-latest # the image our job will run on
name: Test Store # the name that will appear on the Actions UI
steps: # what steps it will perform
- uses: actions/checkout@v4 # checkout whatever branch the PR is using
- uses: bahmutov/[email protected] # trigger an `npm install`
- run: npm run nx test store # test the "store" project
test-api:
runs-on: ubuntu-latest
name: Test API
steps:
- uses: actions/checkout@v4
- uses: bahmutov/[email protected]
- run: npm run nx test api
```

<br />

3. Commit and then switch to a new branch:

```
git add . && git commit -m "add ci"
git push origin master
git checkout -b dynamic-title
```
```
git add . && git commit -m "add ci"
git push origin master
git checkout -b dynamic-title
```

⚠️&nbsp;&nbsp;I know we **just** switched to master above. But it was important we bring it
up to date. Now we need to switch to a new branch so we can submit our PR.
⚠️&nbsp;&nbsp;I know we **just** switched to master above. But it was important we bring it
up to date. Now we need to switch to a new branch so we can submit our PR.

<br />
<br />

4. Open `apps/store/src/app/app.tsx`
<br />
Expand Down Expand Up @@ -126,89 +124,87 @@ But now we're testing both projects - even though we only changed the store.

### Testing only affected

10. Let's use `nx affected` to only test the changed projects:
10. Let's use `nx affected`
Instead of running two `nx` commands in your CI, run a single `nx affected` command
that tests all affected projects.
Instead of running two `nx` commands in your CI, run a single `nx affected` command
that tests all affected projects.
<details>
<summary>🐳 &nbsp;&nbsp;Hint 1</summary>
<details><summary>🐳 &nbsp;&nbsp;Hint 1</summary>
Refer to the [docs](https://nx.dev/nx-api/nx/documents/affected)
</details>
Refer to the [docs](https://nx.dev/nx-api/nx/documents/affected)
</details>
<details>
<summary>🐳 &nbsp;&nbsp;Hint 2</summary>
<details><summary>🐳 &nbsp;&nbsp;Hint 2</summary>
Since it's a Pull Request, your base commit will always be `--base=origin/main`
</details>
Since it's a Pull Request, your base commit will always be `--base=origin/main`
</details>

<details>
<summary>🐳 &nbsp;&nbsp;Hint 3</summary>
<details><summary>🐳 &nbsp;&nbsp;Hint 3</summary>

You should only need 1 job now:
You should only need 1 job now:

```yaml
jobs:
test:
runs-on: ubuntu-latest
name: Testing affected apps
steps:
- uses: actions/checkout@v4
- uses: bahmutov/[email protected]
- run: .....
```
```yaml
jobs:
test:
runs-on: ubuntu-latest
name: Testing affected apps
steps:
- uses: actions/checkout@v4
- uses: bahmutov/[email protected]
- run: .....
```

</details>
</details>

⚠️&nbsp;&nbsp;It's okay to work on this on your new branch. We'll merge everything to `main`
eventually.
⚠️&nbsp;&nbsp;It's okay to work on this on your new branch. We'll merge everything to `main`
eventually.

<br />
<br />

11. Commit and push. On your Github Actions log you should see only the `store` tests running:
11. Commit and push. On your Github Actions log you should see only the `store` tests running:

<img src="./store_affected.png" width="500" alt="Only store tests are running"><br />
<img src="./store_affected.png" width="500" alt="Only store tests are running"><br />

12. Our tests are now being ran sequentially for each project. See if you can run them in parallel (consult the Nx Affected [docs](https://nx.dev/nx-api/nx/documents/affected) if unsure)
1. Our tests are now being ran sequentially for each project. See if you can run them in parallel (consult the Nx Affected [docs](https://nx.dev/nx-api/nx/documents/affected) if unsure)
<br />

13. Our CI only does testing now. But we also have targets for `lint`, `e2e` and `build`. Would really be handy if CI also told us if any of those failed.
2. Our CI only does testing now. But we also have targets for `lint`, `e2e` and `build`. Would really be handy if CI also told us if any of those failed.

**Add more jobs under your CI workflow that run affected for each of the above targets**

<br />

14. Commit and push your `ci.yml` changes.

14. Commit and push your `ci.yml` changes.
<br />

15. You'll notice some new steps in the GitHub Actions UI. Some of them are failing. That is okay. We can fix them later.
15. You'll notice some new steps in the GitHub Actions UI. Some of them are failing. That is okay. We can fix them later.
<br />
16. For now, you can merge your PR into `main `
16. For now, you can merge your PR into `main `
<br />
17. Switch to `main` locally and pull latest so all your new CI changes are up to date.
17. Switch to `main` locally and pull latest so all your new CI changes are up to date.
```shell
git checkout master
git pull origin master
```
```shell
git checkout master
git pull origin master
```
<br />
18. **BONUS:** Currently, if we create a PR with a change **only** to our `ci.yml` file, our `nx affected` commands won't run at all: as they'll think no project has been affected:
<img src="./no_affected.png" width="500" alt="Changes to ci.yml does not cause anything to be affected">
18. **BONUS:** Currently, if we create a PR with a change **only** to our `ci.yml` file, our `nx affected` commands won't run at all: as they'll think no project has been affected:
To be safe, we'd like to mark all projects as affected whenever we change our CI config, as we don't know what those changes could have broken.
Have a look through the docs in the hint and see if you can do this.
<img src="./no_affected.png" width="500" alt="Changes to ci.yml does not cause anything to be affected">
To be safe, we'd like to mark all projects as affected whenever we change our CI config, as we don't know what those changes could have broken.
Have a look through the docs in the hint and see if you can do this.
<details><summary>🐳 &nbsp;&nbsp;Hint</summary>
[Setting named inputs](https://nx.dev/reference/nx-json#inputs-namedinputs)
</details>
<details>
<summary>🐳 &nbsp;&nbsp;Hint</summary>
[Setting named inputs](https://nx.dev/reference/nx-json#inputs-namedinputs)
</details><br />
---
Expand Down
23 changes: 12 additions & 11 deletions docs/lab16/LAB.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,24 @@
10. Let's try a different command - in the same folder you are in, try to run:
```
nx run-many --target=lint --all
```
```
nx run-many --target=lint --all
```
🕑 It should start the linting work, and take a few seconds...
🕑 It should start the linting work, and take a few seconds...
<br />
11. Now let's go back to our main workshop repository and run:
<br />
```
nx run-many --target=lint --all
```
11. Now let's go back to our main workshop repository and run:
⚡ It should pull again from the NxCloud cache...This is even works across laptops! CI will use it as well!
```
nx run-many --target=lint --all
```
<br />
⚡ It should pull again from the NxCloud cache...This is even works across laptops! CI will use it as well!
<br />
---
Expand Down
12 changes: 5 additions & 7 deletions docs/lab18/LAB.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@
⚠️&nbsp;&nbsp;You should see surge deploying to your URL - if you click you'll see just the header though, because it doesn't have a server yet to get the games from.
<br />
```
```
5. Let's now abstract away the above command into an Nx target. Generate a new **"deploy"** target using the `@nx/workspace:run-commands` generator:

Expand Down Expand Up @@ -94,12 +92,12 @@
⚠️&nbsp;&nbsp;Note for Windows users: the command might fail, as we're trying to access env variables the Linux-way.
To make it pass, you can generate a separate `windows-deploy` executor (make sure you keep the existing `deploy` target intact - it will be used by GitHub Actions):
```bash
nx generate run-commands windows-deploy --project=store --command="surge dist/apps/store %SURGE_DOMAIN_STORE% --token %SURGE_TOKEN%"
nx windows-deploy store
```
```bash
nx generate run-commands windows-deploy --project=store --command="surge dist/apps/store %SURGE_DOMAIN_STORE% --token %SURGE_TOKEN%"
nx windows-deploy store
```
<br />
<br />
---
Expand Down
19 changes: 10 additions & 9 deletions docs/lab21-alt/LAB.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,21 @@ In this lab we'll be setting up GitHub actions to build and deploy our projects
3. Our "deploy" targets are using some secret ENV variables though. We'll need to make these available on GitHub: 1. Go to your GitHub workshop repo 2. Click on **"Settings"** at the top 3. Then **"Secrets"** on the left menu bar 4. Add values for all the variables we've been keeping in `.local.env` files

![GitHub secrets](./github_secrets.png)

<br />
<img src="./github_secrets.png" height="300" alt="GitHub secrets">

<br />

4. Then back in our `deploy.yml` file, let's expose these secrets to the processes (use `ci.yml` as an example of where to put these):

```yml
env:
SURGE_DOMAIN_STORE: ${{ secrets.SURGE_DOMAIN_STORE }}
SURGE_DOMAIN_ADMIN_UI: ${{ secrets.SURGE_DOMAIN_ADMIN_UI }}
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
```
```yml
env:
SURGE_DOMAIN_STORE: ${{ secrets.SURGE_DOMAIN_STORE }}
SURGE_DOMAIN_ADMIN_UI: ${{ secrets.SURGE_DOMAIN_ADMIN_UI }}
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
```

<br />
<br />

5. Since we'll be re-deploying, we want to test if we're looking at a new version of our code: - Make a change to your AdminUI (maybe change the text in the header) - Make a change to your Store (maybe change the title in the header)
<br />
Expand Down
Loading

0 comments on commit cc72bab

Please sign in to comment.