Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Update GitHub workflows #60

Merged
merged 2 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/deploy/addon.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash

function setup_wordpress_files() {
# Since it is a plugin deployment, we skip this step
cd "$GITHUB_WORKSPACE"
build_root="$(pwd)"
export build_root
}

function cleanup_node_modules() {
# Since it is a plugin deployment, we skip this step
cd "$GITHUB_WORKSPACE"
# required to remove development dependencies used for building but not required for runtime
npm ci --omit dev
}

function main() {
setup_hosts_file
check_branch_in_hosts_file
setup_ssh_access
maybe_install_submodules
maybe_install_node_dep
maybe_run_node_build
setup_wordpress_files
block_emails
cleanup_node_modules
deploy
}

main
40 changes: 40 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
on:
push:
branches:
- main
- develop
workflow_dispatch:
name: Deploying Headless Server
env:
# Please keep in install-links to avoid npm install errors on the server
build-command: npm i --include-dev --install-links && npm run build:dist
jobs:
deploy:
name: Deploy
runs-on: [ self-hosted, headless ]
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false
steps:
- uses: actions/checkout@v4
- name: Setup hosts file
run: |
cat <<EOF > '${{ github.workspace }}/.github/hosts.yml'
${{ secrets.HOSTS_FILE }}
EOF
- name: Get node version
id: node-version
run: |
cd '${{ github.workspace }}'
NODE_VERSION="$(cat .nvmrc)"
echo "node_version=${NODE_VERSION}" >> "$GITHUB_ENV"
- name: Deploy
uses: rtCamp/action-deploy-wordpress@master
env:
SSH_PRIVATE_KEY: ${{ secrets.ED_DEPLOYMENT_KEY }}
NODE_VERSION: "${{ env.node_version }}"
NODE_BUILD_COMMAND: ${{ env.build-command }}
SSH_USER: ${{ secrets.SSH_USER }}
SSH_HOST: ${{ secrets.SSH_HOST }}
- if: always()
uses: rtCamp/action-cleanup@master
35 changes: 28 additions & 7 deletions .github/workflows/perform-lints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
branches:
- develop
- main
workflow_dispatch:

permissions:
contents: read
Expand Down Expand Up @@ -77,7 +78,7 @@ jobs:
for file in "$PHP_CHANGED_FILES"; do
echo "$file was changed"
done

- name: List all JS changed files
if: steps.changed-files.outputs.js_any_changed == 'true'
env:
Expand Down Expand Up @@ -193,9 +194,9 @@ jobs:
php: [ '8.2' ] #, '8.1' ] @todo reenable when repo is made public
wordpress: [ '6.7' ] #, '6.6' ]
include:
- php: '8.2'
wordpress: '6.7'
coverage: 1
- php: '8.2'
wordpress: '6.7'
coverage: 1
fail-fast: false
steps:
- name: Checkout
Expand Down Expand Up @@ -255,8 +256,24 @@ jobs:
COVERAGE: ${{ matrix.coverage }}
DEBUG: ${{ secrets.ACTIONS_STEP_DEBUG || matrix.debug }}
SUITES: "Integration"
# Todo: Add coveralls + codeclimate


# - name: Push coverage to Coveralls.io
# if: matrix.coverage == 1
# uses: coverallsapp/github-action@v2
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
# path-to-lcov: tests/_output/coverage/lcov.info # todo: verify path
#
# - name: Push coverage to CodeClimate
# if: matrix.coverage == 1
# uses: paambaati/codeclimate-action@v9
# env:
# CC_TEST_REPORTER_ID: <code_climate_reporter_id> # todo: add code climate reporter id
# with:
# debug: true
# coverageLocations: |
# ${{github.workspace}}/tests/_output/*.xml:clover # todo: verify path

playwright:
needs: pre-run
if: needs.pre-run.outputs.changed-workflow == 'true' || needs.pre-run.outputs.changed-js == 'true'
Expand Down Expand Up @@ -296,7 +313,11 @@ jobs:
run: npx playwright install --with-deps

- name: Start wp-env
run: npm run wp-env -- start
run: |
npm run wp-env -- start
sleep 10
netstat -nltp
curl -iL http://localhost:8889

- name: Run E2E tests
run: npm run test:e2e
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/upload-schema-artifact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
release:
types: [ published ]

permissions:
contents: read
actions: write

jobs:
run:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -41,7 +45,7 @@ jobs:

- name: Setup GraphQL Schema Linter
run: npm install -g graphql-schema-linter@^3.0 graphql@^16

- name: Install Node.js dependencies
run: npm ci
env:
Expand Down
Loading