From c8367fbaab222103266c88e555de1272598e25b2 Mon Sep 17 00:00:00 2001 From: Alexander Glasov Date: Tue, 28 Oct 2025 22:25:28 +0300 Subject: [PATCH 1/6] Refactor GitHub Actions workflow for build and test Updated the workflow to use actions/checkout@v4 and added a test job that depends on the build job. --- .github/workflows/test-pipeline.yml | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test-pipeline.yml b/.github/workflows/test-pipeline.yml index b16d2ae..a2f528e 100644 --- a/.github/workflows/test-pipeline.yml +++ b/.github/workflows/test-pipeline.yml @@ -2,17 +2,15 @@ name: Test pipeline run-name: Testing our repository on: [push] jobs: - Build: + build: runs-on: ubuntu-latest steps: - - run: echo "πŸŽ‰ The job was automatically triggered by a ${{ github.event_name }} event." - - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" - - run: echo "πŸ”Ž The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." - - name: Check out repository code - uses: actions/checkout@v5 - - run: echo "πŸ’‘ The ${{ github.repository }} repository has been cloned to the runner." - - run: echo "πŸ–₯️ The workflow is now ready to test your code on the runner." - - name: List files in the repository - run: | - ls ${{ github.workspace }} - - run: echo "🍏 This job's status is ${{ job.status }}." + - uses: actions/checkout@v4 + - run: make build + + test: + runs-on: ubuntu-latest + needs: build + steps: + - uses: actions/checkout@v4 + - run: make test From b5a505a42cbfa2c9f2261c307f987b3feb6b428d Mon Sep 17 00:00:00 2001 From: Alexander Glasov Date: Tue, 28 Oct 2025 22:51:31 +0300 Subject: [PATCH 2/6] Create main.py --- main.py | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..5c251f3 --- /dev/null +++ b/main.py @@ -0,0 +1,2 @@ +def hello(): + return "Hello, CI/CD!" From 58165149da0d763b9417bb86265f16a7b644bf03 Mon Sep 17 00:00:00 2001 From: Alexander Glasov Date: Tue, 28 Oct 2025 22:51:54 +0300 Subject: [PATCH 3/6] Add test for hello function in test_main.py --- test_main.py | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 test_main.py diff --git a/test_main.py b/test_main.py new file mode 100644 index 0000000..c49be78 --- /dev/null +++ b/test_main.py @@ -0,0 +1,4 @@ +from main import hello + +def test_hello(): + assert hello() == "Hello, CI/CD!" From 8f05035b8ee2f563a5e6617cb2597ff6f46a05c6 Mon Sep 17 00:00:00 2001 From: Alexander Glasov Date: Tue, 28 Oct 2025 22:53:32 +0300 Subject: [PATCH 4/6] Create ci.yml --- .github/workflows/ci.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..9087a3a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,25 @@ +name: CI + +on: + push: + branches: [ main ] + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + + - name: Install dependencies + run: pip install pytest + + - name: Run tests + run: pytest From eb02d87ff9cbed7608e0d7dd70a7c0448ca212ef Mon Sep 17 00:00:00 2001 From: Alexander Glasov Date: Tue, 28 Oct 2025 23:01:23 +0300 Subject: [PATCH 5/6] Add GitHub Actions workflow for releases This workflow automates the release process on tag pushes. --- .github/workflows/cd.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/cd.yml diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..3e6afc8 --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,22 @@ +name: Release + +on: + push: + tags: + - 'v*.*.*' + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Build project + run: echo "Π‘ΠΎΠ±ΠΈΡ€Π°Π΅ΠΌ ΠΏΡ€ΠΎΠ΅ΠΊΡ‚..." + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + name: Release ${{ github.ref_name }} + body: АвтоматичСский Ρ€Π΅Π»ΠΈΠ· Π½ΠΎΠ²ΠΎΠΉ вСрсии From 6204f884f6e72fa217734ceeef9356ec7f543ee0 Mon Sep 17 00:00:00 2001 From: Alexander Glasov Date: Tue, 28 Oct 2025 23:16:44 +0300 Subject: [PATCH 6/6] Update cd.yml --- .github/workflows/cd.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 3e6afc8..ab3eee9 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -5,18 +5,22 @@ on: tags: - 'v*.*.*' +permissions: + contents: write + jobs: release: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - name: Build project - run: echo "Π‘ΠΎΠ±ΠΈΡ€Π°Π΅ΠΌ ΠΏΡ€ΠΎΠ΅ΠΊΡ‚..." + run: echo "Building..." - name: Create GitHub Release uses: softprops/action-gh-release@v2 with: name: Release ${{ github.ref_name }} body: АвтоматичСский Ρ€Π΅Π»ΠΈΠ· Π½ΠΎΠ²ΠΎΠΉ вСрсии + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}