From d35f6cee39110bfda071c11654eac6107fb6b7dc Mon Sep 17 00:00:00 2001 From: yuxuanliuliuliu Date: Fri, 11 Apr 2025 18:32:23 -0400 Subject: [PATCH 1/4] change readme to test workflow --- README.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 29a4ae9..dcc2055 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Read the complete reference to [Github Actions Workflow Syntax](https://docs.git ## Repository structure -The repository has a Node server (`server.ts`) written using the Express framework. The server provides REST APIs to query books, authors, and details about specific books and authors. The services use a MongoDB database to store related data. The schema for the relevant MongoDB collections are defined in `models/`. The Express services communicate with the underlying MongoDB collections using the ORM/ODM Mongoose layer. Additonally, the `tests/` directory has a few Jest tests to verify the behavior of some of the services. +The repository has a Node server (`server.ts`) written using the Express framework. The server provides REST APIs to query books, authors, and details about specific books and authors. The services use a MongoDB database to store related data. The schema for the relevant MongoDB collections are defined in `models/`. The Express services communicate with the underlying MongoDB collections using the ORM/ODM Mongoose layer. Additonally, the `tests/` directory has a few Jest tests to verify the behavior of some of the services. ## Setup Actions @@ -15,9 +15,9 @@ One can setup any GitHub repository with GitHub Actions. This means based on eve - In your forked repo naviagte to the **Settings** tab. - In **Settings**, navigate to **Actions/Runner** on the left pane. - It will say you have no runners configured. -- Click on **New self-hosted runner**. +- Click on **New self-hosted runner**. - Follow the instructions to setup and start the runner. -- When you configure the runner and start it, it will be listed the Runners page saying __Idle__ with a green color indicating is up and running. +- When you configure the runner and start it, it will be listed the Runners page saying **Idle** with a green color indicating is up and running. - When the YAML workflow described below runs, it will run on this self-hosted runner, which happens to be your machine. By following the above steps, you will have configured your machine to be self-hosted actions runner. A similar concept applies for runners configured to run on cloud servers. @@ -26,7 +26,7 @@ By following the above steps, you will have configured your machine to be self-h Imagine a team of developers working on this project. Anytime they make a change, they need to ensure that the existing functionality did not break. Hence, they design an automatic workflow that does the following: -Everytime code is pushed to the main branch, all jest tests run and a report of the run is published for all team members to view. If the tests fail then the repository is in a bad state and needs to be fixed immediately before proceeding. +Everytime code is pushed to the main branch, all jest tests run and a report of the run is published for all team members to view. If the tests fail then the repository is in a bad state and needs to be fixed immediately before proceeding. The team also maintains a deploy branch. This branch needs to be kept in a valid state at all times because, code from this branch is used in production. Therefore, the above workflow also gets triggered when a pull request is made to the deploy branch. @@ -34,7 +34,7 @@ All this represented in the `.github/workflows/main.yml` file. ## For you to do -First setup your machine or your teammate's machine to be the self hosted runner using the instructions in __Setup__. +First setup your machine or your teammate's machine to be the self hosted runner using the instructions in **Setup**. - Create a deploy branch if it doesn't already exist - Submit a pull request to the deploy branch from main @@ -42,4 +42,6 @@ First setup your machine or your teammate's machine to be the self hosted runner Create a new workflow yml file that captures the following continuous integration requirement: -- When new changes are pushed to the deploy branch, the sample data should be setup using the scripts in `remove_db.ts` and `insert_sample_db.ts`. \ No newline at end of file +- When new changes are pushed to the deploy branch, the sample data should be setup using the scripts in `remove_db.ts` and `insert_sample_db.ts`. + +make some change to the main branch From e324ee3d321de7131b0b44fcc36930f6fd7f77dc Mon Sep 17 00:00:00 2001 From: yuxuanliuliuliu Date: Fri, 11 Apr 2025 18:53:51 -0400 Subject: [PATCH 2/4] add yml file for deploy --- .github/workflows/setup-sample-data.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/setup-sample-data.yml diff --git a/.github/workflows/setup-sample-data.yml b/.github/workflows/setup-sample-data.yml new file mode 100644 index 0000000..f340f38 --- /dev/null +++ b/.github/workflows/setup-sample-data.yml @@ -0,0 +1,23 @@ +name: Setup Sample Data + +on: + push: + branches: + - deploy + +jobs: + "setup-sample-data": + runs-on: self-hosted + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Install dependencies + run: npm install + + - name: Clear Database + run: npx ts-node remove_db.ts "mongodb://127.0.0.1:27017/my_library_db" + + - name: Insert Sample Data + run: npx ts-node insert_sample_data.ts "mongodb://127.0.0.1:27017/my_library_db" From 175c476e3a4d800156585cdc4ba449dbfef966b8 Mon Sep 17 00:00:00 2001 From: yuxuanliuliuliu Date: Fri, 11 Apr 2025 19:02:20 -0400 Subject: [PATCH 3/4] change readme --- README.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 29a4ae9..2a1769e 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Read the complete reference to [Github Actions Workflow Syntax](https://docs.git ## Repository structure -The repository has a Node server (`server.ts`) written using the Express framework. The server provides REST APIs to query books, authors, and details about specific books and authors. The services use a MongoDB database to store related data. The schema for the relevant MongoDB collections are defined in `models/`. The Express services communicate with the underlying MongoDB collections using the ORM/ODM Mongoose layer. Additonally, the `tests/` directory has a few Jest tests to verify the behavior of some of the services. +The repository has a Node server (`server.ts`) written using the Express framework. The server provides REST APIs to query books, authors, and details about specific books and authors. The services use a MongoDB database to store related data. The schema for the relevant MongoDB collections are defined in `models/`. The Express services communicate with the underlying MongoDB collections using the ORM/ODM Mongoose layer. Additonally, the `tests/` directory has a few Jest tests to verify the behavior of some of the services. ## Setup Actions @@ -15,9 +15,9 @@ One can setup any GitHub repository with GitHub Actions. This means based on eve - In your forked repo naviagte to the **Settings** tab. - In **Settings**, navigate to **Actions/Runner** on the left pane. - It will say you have no runners configured. -- Click on **New self-hosted runner**. +- Click on **New self-hosted runner**. - Follow the instructions to setup and start the runner. -- When you configure the runner and start it, it will be listed the Runners page saying __Idle__ with a green color indicating is up and running. +- When you configure the runner and start it, it will be listed the Runners page saying **Idle** with a green color indicating is up and running. - When the YAML workflow described below runs, it will run on this self-hosted runner, which happens to be your machine. By following the above steps, you will have configured your machine to be self-hosted actions runner. A similar concept applies for runners configured to run on cloud servers. @@ -26,7 +26,7 @@ By following the above steps, you will have configured your machine to be self-h Imagine a team of developers working on this project. Anytime they make a change, they need to ensure that the existing functionality did not break. Hence, they design an automatic workflow that does the following: -Everytime code is pushed to the main branch, all jest tests run and a report of the run is published for all team members to view. If the tests fail then the repository is in a bad state and needs to be fixed immediately before proceeding. +Everytime code is pushed to the main branch, all jest tests run and a report of the run is published for all team members to view. If the tests fail then the repository is in a bad state and needs to be fixed immediately before proceeding. The team also maintains a deploy branch. This branch needs to be kept in a valid state at all times because, code from this branch is used in production. Therefore, the above workflow also gets triggered when a pull request is made to the deploy branch. @@ -34,7 +34,7 @@ All this represented in the `.github/workflows/main.yml` file. ## For you to do -First setup your machine or your teammate's machine to be the self hosted runner using the instructions in __Setup__. +First setup your machine or your teammate's machine to be the self hosted runner using the instructions in **Setup**. - Create a deploy branch if it doesn't already exist - Submit a pull request to the deploy branch from main @@ -42,4 +42,5 @@ First setup your machine or your teammate's machine to be the self hosted runner Create a new workflow yml file that captures the following continuous integration requirement: -- When new changes are pushed to the deploy branch, the sample data should be setup using the scripts in `remove_db.ts` and `insert_sample_db.ts`. \ No newline at end of file +- When new changes are pushed to the deploy branch, the sample data should be setup using the scripts in `remove_db.ts` and `insert_sample_db.ts`. + change readme to test workflow From 78608410a3f2576deaf1e601830b847f607f87e6 Mon Sep 17 00:00:00 2001 From: yuxuanliuliuliu Date: Fri, 11 Apr 2025 20:23:48 -0400 Subject: [PATCH 4/4] change label --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9877da5..d08913a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,7 +11,7 @@ on: jobs: "run-jest-tests": - runs-on: cs5500-self-hosted + runs-on: self-hosted steps: - name: Checkout Repository uses: actions/checkout@v3