Skip to content

Commit

Permalink
feat: add dependabot (#12)
Browse files Browse the repository at this point in the history
* feat: add dependabot

* fix: wait-on in cypress

* fix: dependencies added to auto-merge.yml file

* fix: ruby added to auto-merge.yml file

* fix: extract port from base url if api url is not provided

* fix: wait-on timout loaded from variables and listen to port instead of url

* fix: cypress updated to 12.17.1

* fix: step added to run test if api url is set

* fix: write permission added to the workflow and automerge will be triggered on patch update

* fix: automerge will be triggered on all update

---------

Co-authored-by: Ehsan Mirzarazi <[email protected]>
Co-authored-by: Ehsan Mirzarazi <[email protected]>
  • Loading branch information
3 people authored Feb 21, 2024
1 parent 832706a commit 9dd3fba
Show file tree
Hide file tree
Showing 9 changed files with 597 additions and 143 deletions.
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/app-express"
schedule:
interval: "daily"
labels:
- "npm"
- "dependencies"
- package-ecosystem: "npm"
directory: "/app-react"
schedule:
interval: "daily"
labels:
- "npm"
- "dependencies"
77 changes: 77 additions & 0 deletions .github/workflows/auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Tests and Dependabot PR Handling

on:
pull_request:
branches:
- master
- main
permissions:
contents: write
pull-requests: write

jobs:
# Verifies the boilerplate can start and run in GitHub Actions environment
test-for-workflow:
name: Alva test workflow
uses: DevSkillsHQ/publish-test-results-workflow/.github/workflows/publish-test-results.yml@main

# Verifies the boilerplate can start and run in codespace environment
test-for-codespaces:
runs-on: ubuntu-20.04
permissions:
contents: read
packages: read
container:
image: ghcr.io/devskillshq/boilerplate-base-image:latest
credentials:
username: ${{ github.actor }}
password: ${{ secrets.github_token }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install jq
run: sudo apt-get install jq
- name: Fetch apiUrl
run: |
apiUrl=$(grep "apiUrl:" cypress.config.js | awk -F": " '{print $2}' | tr -d "'," || echo "")
if [[ ! -z "$apiUrl" ]]; then
apiUrl="$apiUrl/ping"
fi
echo "apiUrl=$apiUrl" >> $GITHUB_ENV
shell: bash
# Running tests for all challenges except Backend.
- name: Run tests without waiting on API
if: env.apiUrl == ''
uses: cypress-io/github-action@v5
with:
build: npm run build
start: npm run start
- name: Run tests with waiting on API
if: env.apiUrl != ''
uses: cypress-io/github-action@v5
with:
build: npm run build
start: npm run start
wait-on: ${{ env.apiUrl }}


auto-merge-dependabot:
needs:
- test-for-workflow
- test-for-codespaces
runs-on: ubuntu-20.04
if: github.actor == 'dependabot[bot]'
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Enable auto-merge for Dependabot PRs
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
40 changes: 0 additions & 40 deletions .github/workflows/tests.yml

This file was deleted.

12 changes: 12 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const { defineConfig } = require('cypress')

module.exports = defineConfig({
env: {
apiUrl: 'http://localhost:5000',
},
e2e: {
supportFile: false,
setupNodeEvents(on, config) {},
baseUrl: 'http://localhost:3000',
},
})
6 changes: 0 additions & 6 deletions cypress.json

This file was deleted.

File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 9dd3fba

Please sign in to comment.