Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
tulna07 committed Sep 20, 2024
1 parent b403fab commit 438035e
Show file tree
Hide file tree
Showing 12 changed files with 147 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ Please begin by reading the following subsections, *Experiment n* (where *n* ran

![0002](/images/13/2/0002.svg?featherlight=false&width=100pc)

**3.** Choose your favorite workspace on your local machine. Clone this remote repository [github.com/Definitely-not-AWS-Workshops/get-1s](https://github.com/Definitely-not-AWS-Workshops/get-1s).
**3.** Scroll down to the botttom. Click **Create repository**.

![00010](/images/4/1/00010.svg?featherlight=false&width=100pc)

**4.** Choose your favorite workspace on your local machine. Clone this remote repository [github.com/Definitely-not-AWS-Workshops/get-1s](https://github.com/Definitely-not-AWS-Workshops/get-1s).

```git
git clone https://github.com/Definitely-not-AWS-Workshops/get-1s
Expand Down Expand Up @@ -67,43 +71,43 @@ jobs:
In general, this workflow is triggered when a pull request is created or when a branch is part of a *merge group* (*main* branch). It sets up a CI job on an Ubuntu machine, checks out the code, installs Python 3.9, prints the contents of two files (*main.py* and *test.py*) for troubleshooting, and finally runs the test file (*test.py*) to validate the code changes. The sleep 10 step appears to add a delay, possibly for debugging purposes.
**4.** Change the directory name to `experiment-n` where *n* is the experimental subsection you are working on.
**5.** Change the directory name to `experiment-n` where *n* is the experimental subsection you are working on.

```git
mv get-1s experiment-n
```

**5.** Change into the directory `experiment-n` where *n* is the experimental subsection you are working on. And then remove the *.git* folder.
**6.** Change into the directory `experiment-n` where *n* is the experimental subsection you are working on. And then remove the *.git* folder.

```git
cd experiment-n && rm -rf .git
```

**6.** Initialize a new git repository.
**7.** Initialize a new git repository.

```git
git init
```

**7.** Link to the remote repository that you have just created with `experiment-n` where *n* is the experimental subsection you are working on
**8.** Link to the remote repository that you have just created with `experiment-n` where *n* is the experimental subsection you are working on

```git
git remote add origin https://github.com/fcj-workshops-2024/experiment-n.git
```

**8.** Make your first commit and push to the remote repository.
**9.** Make your first commit and push to the remote repository.

```git
git add . && git commit -m "first commit" && git push --set-upstream origin main
```

**9.** Create and switch to the *person-a* branch.
**10.** Create and switch to the *person-a* branch.

```git
git checkout -b person-a
```

**10.** In the *main.py* file, change the default value of the parameter *n* from `DEFAULT` to `7`.
**11.** In the *main.py* file, change the default value of the parameter *n* from `DEFAULT` to `7`.

```python {linenos=table,hl_lines=["3-4"],linenostart=1}
DEFAULT=1
Expand All @@ -118,7 +122,7 @@ DEFAULT=1
return [1] * n
```

**11.** Run the test.
**12.** Run the test.

```git
python test.py
Expand All @@ -128,25 +132,25 @@ It should be successful for your test to run.

![0003](/images/13/2/0003.svg?featherlight=false&width=100pc)

**12.** Make a commit.
**13.** Make a commit.

```git
git add . && git commit -m "change the default value of the parameter n from DEFAULT to 7"
```

**13.** Switch to the *main* branch.
**14.** Switch to the *main* branch.

```git
git checkout main
```

**14.** Create and switch to the *person-b* branch.
**15.** Create and switch to the *person-b* branch.

```git
git checkout -b person-b
```

**15.** Make a change to *main.py* file.
**16.** Make a change to *main.py* file.

```python {linenos=table,hl_lines=["9-10"],linenostart=1}
DEFAULT=1
Expand All @@ -161,7 +165,7 @@ def get_1s(n=DEFAULT):
+ return [1] * (30 if n==DEFAULT else n)
```

**16.** Add a test to *test.py* file.
**17.** Add a test to *test.py* file.

```python {linenos=table,hl_lines=["12-16"],linenostart=1}
import unittest
Expand All @@ -186,7 +190,7 @@ if __name__ == "__main__":
```

**17.** Run the test.
**18.** Run the test.

```git
python test.py
Expand All @@ -196,7 +200,7 @@ It should be successful for your test to run.

![0004](/images/13/2/0004.svg?featherlight=false&width=100pc)

**18.** Make a commit.
**19.** Make a commit.

```git
git add . && git commit -m "modify the get_1s return and add another test"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ git push --set-upstream origin person-b

![00010](/images/13/3/00010.svg?featherlight=false&width=100pc)

**16.** Expand the **Show main.py content** step dropdown, and you might notice the default value of *n* is now 7. You should recall that person *b* did not modify this in his code changes (see step **15** in [13.2 Prepare Source Code](13-experiments-with-gitHub-actions-merge-group/2-prepare-source-code)).
**16.** Expand the **Show main.py content** step dropdown, and you might notice the default value of *n* is now 7. You should recall that person *b* did not modify this in his code changes (see step **16** in [13.2 Prepare Source Code](13-experiments-with-gitHub-actions-merge-group/2-prepare-source-code)).

![00011](/images/13/3/00011.svg?featherlight=false&width=100pc)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ GitHub Actions also provides the flexibility to control concurrency with [concur

Therefore, with *concurrency group*,

- **Running Tests on Feature Branches** can be enhanced with a *concurrency group*, which automatically cancels any ongoing tests when a new commit is pushed to the same branch. This ensures that only the most recent changes are evaluated.

- **Continuous Deployment to Production Environment** can be streamlined by utilizing a *concurrency group*, which ensures that only one deployment is active at any given time for a specific environment. If a new commit is pushed, the current deployment can be canceled, allowing only the latest version to be deployed seamlessly.

- **Running Tests on Feature Branches** can be enhanced with a *concurrency group*, which automatically cancels any ongoing tests when a new commit is pushed to the same branch. This ensures that only the most recent changes are evaluated.
To keep the AWSome Books project organized and tidy, it is a great idea to conduct experiments separately. Next, let’s run a series of experiments to compare the results with and without this feature. This way, we can clearly evaluate its impact!
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,53 @@ pre : " <b> 14.2 </b> "
- For **Repository name**, enter `experiment-5-6-7`
- Select **Public** option.

![0002](/images/14/2/0001.svg?featherlight=false&width=100pc)
![0002](/images/14/2/0001.svg?featherlight=false&width=100pc)

**3.** Scroll down to the botttom. Click **Create repository**.

![0003](/images/4/1/00010.svg?featherlight=false&width=100pc)

**4.** Choose your favorite workspace on your local machine. Next, create and move to the experiment folder.

```git
mkdir experiment-5-6-7 && cd experiment-5-6-7
```

**5.** Initialize the local git repository.

```git
git init
```

**6.** Link to the remote repository that you have just created.

```git
git remote add origin https://github.com/fcj-workshops-2024/experiment-5-6-7.git
```

**7.** Create *.github/workflows/main.yml* file.

```git
mkdir -p .github/workflows && touch .github/workflows/main.yml
```

**8.** Add the following content to *.github/workflows/main.yml* file:

```yml
name: main

on:
push:
branches: ["main"]

jobs:
run-test:
runs-on: ubuntu-latest
steps:
- name: Extend the workflow duration by an additional 180 seconds.
run: sleep 180
```
Overall, this workflow serves a very basic purpose: it will trigger whenever there is a push to the *main* branch and will extend the execution time by 180 seconds for testing or to simulate a longer running job.
Next, let’s first dive into the fifth experiment without utilizing the *concurrency group*.
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,50 @@ chapter : false
pre : " <b> 14.3 </b> "
---

Without concurency group
In this section, let’s experiment by running two workflow executions without utilizing *concurrency group*. Let’s find out what happens!

**1.** Make sure you are still in the right project folder.

```git
cd path/to/experiment-5-6-7
```

**2.** Add the following content to *README.md* file.

```git
echo "experiment 5: the first workflow execution!" > README.md
```

**3.** Make your first commit and push to the remote repository.

```git
git add . && git commit -m "experiment 5: the first workflow execution" && git push --set-upstream origin main
```

**4.** On your remote repository, click the **Actions** tab, you should see that a workflow execution has been triggered.

![0001](/images/14/3/0001.svg?featherlight=false&width=100pc)

**5.** In your local repository, update the *README.md* file with the following content.

```git
echo "experiment 5: the second workflow execution!" > README.md
```

**6.** Make another commit and push to the remote repository.

```git
git add . && git commit -m "experiment 5: the second workflow execution" && git push
```

**7.** On your remote repository, under the **Actions** tab, while the first workflow execution is running, you may notice that another workflow has been triggered and is now running as well.

![0002](/images/14/3/0002.svg?featherlight=false&width=100pc)

As you can see, GitHub Actions enables multiple workflow runs to occur simultaneously by default, which can lead to the drawbacks we discussed in the previous section.






Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
title : "Experiment With GitHub Actions Concurrency Group"
title : "Experiments With GitHub Actions Concurrency Group"
date : "`r Sys.Date()`"
weight : 14
chapter : false
pre : " <b> 14. </b> "
---

Let's conduct a series of experiments, independent of the AWSome Books project, to explore how implementing *concurrency group*s can significantly enhance CI/CD pipeline efficiency.
Let's first explore several situations to understand why you might need the *concurrency group* feature. Then, you can conduct a series of experiments, independent of the AWSome Books project, to examine how implementing *concurrency group*s can significantly enhance the efficiency of the CI/CD pipeline.

#### Content

Expand Down
4 changes: 4 additions & 0 deletions static/images/14/2/0001.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions static/images/14/3/0001.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions static/images/14/3/0001.svg.1.crswap

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions static/images/14/3/0001.svg.crswap

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions static/images/14/3/0002.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions static/images/14/3/0002.svg.crswap

Large diffs are not rendered by default.

0 comments on commit 438035e

Please sign in to comment.