This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Why this block? | |
GITHUB_WORKFLOW env variable is only available in GitHub Actions. So in actions | |
we want a simple postgres docker image to be booted as a service and does all the testing there. | |
When we deploy to cloud the else block will work as we won't be having GITHUB_WORKFLOW env var in our deployment. | |
That time the db config we use DB_USER, DB_NAME, DB_PASSWORD, DB_HOST and DB_PASSWORD | |
which we will set in repository secret to be used in our deployment. | |
''' | |
if os.getenv('GITHUB_WORKFLOW'): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.test import TestCase | |
from django.contrib.auth.models import User | |
# Create your tests here. | |
class UserTestCase(TestCase): | |
def test_user(self): | |
username = 'shetu' | |
password = 'hello' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Sample Workflow | |
on: | |
push: # enabling push event on master branch to fire the workflow | |
branches: | |
- master | |
jobs: | |
job1: | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout out current code using public action |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Under each job there is a keyword called steps | |
# steps contains list of step | |
# In here will simply explain single step block | |
# as steps are list, if one fails, the next steps are skipped. There are ways to trigger it to. | |
# name of the step | |
name: name of the step | |
id: sample_id # needed if this step has output to be used in other steps | |
run: echo 'Hello World' # command we want to run |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# there might be multiple jobs definition under jobs. | |
# this is the job annotation. It can contain multiple job | |
# in each job definition runs-on and steps are required. | |
jobs: | |
# name of the job to be shown in GitHub | |
first-job: | |
# os in which the job will run | |
# Possible values are ubuntu-latest, windows-latest, ubuntu-16.04 | |
# there might be many version. | |
runs-on: ubuntu-latest # required |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# You can have environment variables in the workflow | |
# this will be available in each job and steps inside it. | |
env: | |
PROJECT_ID: sample-project-id | |
USERNAME: sample-username | |
# So now in each steps you can access them by $PROJECT_ID or $USERNAME | |
# Normally the environment variables will show their value when printed in logs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Each workflow is triggered on some events | |
# will be triggered on push | |
on: push | |
# will be triggered on push and create pull_request | |
on: [push, pull_request] | |
# You can also have some configuration like this | |
on: | |
push: # will be triggered for any push |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Each workflow must have a name | |
# Here the workflow will be named as Sample Workflow | |
name: Sample workflow |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: networking.istio.io/v1alpha3 | |
kind: VirtualService | |
metadata: | |
name: microservice-virtual-service | |
namespace: traffic-management | |
spec: | |
hosts: | |
- traffic-management.retailvoice.xyz #allowed host | |
gateways: | |
- traffic-management/ingressgateway # list of gateway from which we will be getting request forwarded |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: networking.istio.io/v1alpha3 | |
kind: VirtualService | |
metadata: | |
name: user-virtual-service #self explanatory | |
namespace: traffic-management #self explanatory | |
spec: | |
hosts: # a virtual service can redirect requests for multiple hosts. this is more of a filtering hosts | |
- user.traffic-management.retailvoice.xyz | |
gateways: # a virtual service can also received requests from multiple gateway | |
- traffic-management/ingressgateway # always safe to access with namespaces |