Skip to content

47 workflow merge main check for pull requests #28

47 workflow merge main check for pull requests

47 workflow merge main check for pull requests #28

Workflow file for this run

name: Linting, prettier and Testing
on: #this workflow runs on pull requests and pushes to main or master
pull_request:
branches: [main, master]
push:
branches: [main, master]
#this is a list of all jobs
jobs:
check-main-merge-status:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check if up-to-date with main branch
run: |
git fetch origin main:main
DIFF=$(git diff --name-only HEAD main)
if [ "$DIFF" ]; then
echo "Error: Branch is not up-to-date with main. Please merge the latest main into your branch."
exit 1
fi
linting:
runs-on: ubuntu-latest
steps:
- name: Checkout #checks out our current branch so this runner has the latest code
uses: actions/checkout@v4 #uses means that it is a pre-defined action supplied by GitHub.
- name: Setup Node
uses: actions/setup-node@v3 #this is also a pre-defined action
with:
node-version: 20
- name: NPM Install #we now need to install all our dependencies in this environment
run: npm ci #npm clean install - does not write to package.json
- name: Run linting
run: npm run lint
- name: Run prettier
run: npm run prettierW
testing: #name of first job
runs-on: ubuntu-latest #sets the env which this job runs on
needs: linting
steps: #defines the steps necessary
- name: Checkout #checks out our current branch so this runner has the latest code
uses: actions/checkout@v4 #uses means that it is a pre-defined action supplied by GitHub.
- name: Setup Node
uses: actions/setup-node@v3 #this is also a pre-defined action
with:
node-version: 20
- name: NPM Install #we now need to install all our dependencies in this environment
run: npm ci #npm clean install - does not write to package.json
- name: Run tests #if npm test throws and error this workflow fails.
run: npm test