Skip to content

Commit

Permalink
test CI/CD pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
sashhhaka committed Jul 21, 2024
1 parent 6fde414 commit 95aabd0
Showing 1 changed file with 23 additions and 63 deletions.
86 changes: 23 additions & 63 deletions .github/workflows/test-code.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# .github/workflows/test-code.yaml

# Name of the workflow
name: Test code

# Trigger when?
Expand All @@ -7,83 +10,54 @@ on:
- main
- dev
paths: # the push should be specifically to the folders `src` or `scripts` to trigger this workflow, otherwise, the workflow will not be triggered
- 'src'
- 'scripts'
- 'services/airflow/dags'
- 'tests'
- 'configs'
- '.github'
# Run this workflow on a scheduled manner given the cron expression (This is a second event to trigger the workflow)
- 'src/**'
- 'scripts/**'
- 'services/airflow/dags/**'
- 'tests/**'
- 'configs/**'
- '.github/**'
schedule:
- cron: '*/5 * * * *'

# Allows to only read the contents of the repository
# `contents: read` permits an action to list the commits
# `contents: write` allows the action to create a release
permissions:
contents: read

# Decalre environment variables to be used in this workflow file
# Declare environment variables to be used in this workflow file
env:
message: "Testing code!"

# Tasks
jobs:

# Task name
test-code:

# OS to run the task
runs-on: ubuntu-latest # The ubuntu-latest label currently uses the Ubuntu 22.04 runner image

# for more info about the given resources, check this link below
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories

defaults: # Set working directory of the job
run:
shell: bash # Set the default shell
working-directory: .

# The steps of the task/job
steps:

# Task name
- name: Checking out our code
# Action type
# This action check out the repository in the runner.
uses: actions/checkout@v4
# for more info, check the link below
# https://github.com/actions/checkout

# Install a version of Python
- name: setup python
uses: actions/setup-python@v5
# for more info, check the link below
# https://github.com/actions/setup-python

# Install this specific version 3.11.0 of Python
with:
python-version: '3.11.0'
cache: 'pip' # caching pip dependencies

# Install Python packages
- name: install python packages

# `run` allows to run shell commands
# We can use operator `|` for a multi-line command
run: |
python3.11 -m pip install --upgrade pip
pip3.11 install -r requirements.txt
# You do not need to create a virtual environment here, just use the global installation of Python
# Check if requirements.txt file is there
# if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
python3.11 -m pip install --upgrade pip
pip3.11 install -r requirements.txt
# Task name
- name: Run your app

# A one-line shell command
# This will run the application in the background
# It is useful for apps which block the shell
# to allow next commands to run
run: python3.11 src/app.py &

- name: Export variables
Expand All @@ -97,32 +71,18 @@ jobs:
- name: Run ZenML server
run: zenml down && zenml up

# Run pytest on tests folder
- name: Test with pytest
run: pytest tests



# Another job
print_info:
runs-on: ubuntu-latest
needs: test-code
steps:
- name: print my password
run: |
echo My password is ${{ secrets.PASSWORD }}
echo My name is '${{ vars.NAME }}'
runs-on: ubuntu-latest


# Run this job after running the job `test-code`
# This allows to set dependency between the jobs
needs: test-code


steps:

# Print passwords and some variables defined on Github website
- name: print my password
run: |
echo My password is ${{ secrets.PASSWORD }}
echo My name is '${{ vars.NAME }}'
# Print some message defined as environment variable
- name: print message
run: echo $message

- name: print message
run: echo $message

0 comments on commit 95aabd0

Please sign in to comment.