Skip to content

Instantly share code, notes, and snippets.

View nashmaniac's full-sized avatar
😃
Happy Always

Raju Ahmed Shetu nashmaniac

😃
Happy Always
  • KOHO Financial Inc
  • Toronto, Canada
View GitHub Profile
'''
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'):
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'
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
@nashmaniac
nashmaniac / action-step.yaml
Last active June 2, 2020 02:09
Step Definition
# 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
@nashmaniac
nashmaniac / action-job.yaml
Last active June 2, 2020 02:08
Job Definition
# 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
@nashmaniac
nashmaniac / action-env.yaml
Last active June 1, 2020 13:45
environement variables
# 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
@nashmaniac
nashmaniac / action-on.yaml
Created May 31, 2020 21:06
Action Trigger
# 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
@nashmaniac
nashmaniac / action-name.yaml
Created May 31, 2020 20:44
action-name.yaml
# Each workflow must have a name
# Here the workflow will be named as Sample Workflow
name: Sample workflow
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
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