Skip to content

Commit

Permalink
Better github actions tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pookmish committed Jul 12, 2024
1 parent 14e2208 commit a3ed7f8
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 17 deletions.
6 changes: 3 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ NEXT_PUBLIC_DRUPAL_BASE_URL=https://dev.next-drupal.org
#DRUPAL_BASIC_AUTH_ADMIN=foo:bar


# Change this to 'true' to fetch all pages and build each one.
# Recommended to enable this for production environment.
#BUILD_COMPLETE=false
# During `yarn build` process, indicate how many pages should be build.
# To build everything, set the value to -1. To build nothing, set the value to 0.
BUILD_PAGES=0

# Set this environment variable on the production environment only at launch. This will be used for the
# /sitemap.xml and allow search indexing on the site.
Expand Down
83 changes: 73 additions & 10 deletions .github/workflows/build_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ jobs:
container:
image: node:20
env:
NEXT_PUBLIC_DRUPAL_BASE_URL: ${{ secrets.NEXT_PUBLIC_DRUPAL_BASE_URL }}
DRUPAL_BASIC_AUTH: ${{ secrets.DRUPAL_BASIC_AUTH }}
DRUPAL_BASIC_AUTH_ADMIN: ${{ secrets.DRUPAL_BASIC_AUTH_ADMIN }}
NEXT_PUBLIC_DRUPAL_BASE_URL: http://localhost
steps:
- uses: actions/checkout@v4
- name: Restore Cache
Expand All @@ -19,16 +17,81 @@ jobs:
path: |
node_modules
.next
key: 1.x-${{ hashFiles('package.json') }}-${{ hashFiles('yarn.lock') }}
key: lint-${{ hashFiles('package.json') }}-${{ hashFiles('yarn.lock') }}
restore-keys: |
1.x-${{ hashFiles('package.json') }}-${{ hashFiles('yarn.lock') }}
1.x-${{ hashFiles('package.json') }}-
1.x-
lint-${{ hashFiles('package.json') }}-${{ hashFiles('yarn.lock') }}
lint-${{ hashFiles('package.json') }}-
- name: Lint
run: |
yarn
yarn next telemetry disable
yarn lint
# - name: Build
# run: |
# yarn build
build:
name: Build
runs-on: ubuntu-latest
container:
image: pookmish/drupal8ci:latest
env:
BUILD_PAGES: 100
services:
mysql:
image: mysql:5.7
env:
MYSQL_DATABASE: drupal
MYSQL_USER: drupal
MYSQL_PASSWORD: drupal
MYSQL_ROOT_PASSWORD: drupal
ports:
- 33306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
# - name: Install SSH key
# uses: shimataro/ssh-key-action@v2
# with:
# key: ${{ secrets.SSH_KEY }}
# name: id_rsa
# known_hosts: ${{ secrets.KNOWN_HOSTS }}
# if_key_exists: fail
- uses: actions/checkout@v4
with:
repository: "SU-SWS/ace-stanfordlagunita"
- uses: actions/checkout@v4
with:
path: frontend
- name: Restore Cache
uses: actions/cache@v4
with:
path: |
vendor
docroot/core
docroot/libraries
docroot/modules/contrib
frontend/node_modules
key: build-${{ hashFiles('blt/blt.yml') }}-${{ hashFiles('composer.json') }}-${{ hashFiles('composer.lock') }}
restore-keys: |
build-${{ hashFiles('blt/blt.yml') }}-${{ hashFiles('composer.json') }}-${{ hashFiles('composer.lock') }}
build-${{ hashFiles('blt/blt.yml') }}-${{ hashFiles('composer.json') }}-
build-${{ hashFiles('blt/blt.yml') }}-
- name: Sync Site
run: |
git config --system --add safe.directory '*' &&
mysql -h mysql -P 3306 -u root -pdrupal -e 'SET GLOBAL max_allowed_packet=67108864;' &&
rm -rf /var/www/html &&
ln -snf $GITHUB_WORKSPACE /var/www/html &&
mkdir -p docroot/sites/default/files &&
chmod -R 777 docroot/sites/default/files/ &&
rm -rf docroot/sites/summer/files &&
ln -sL ../default/files/ docroot/sites/summer/files &&
apachectl stop && apachectl start &&
composer install -n &&
blt drupal:install -n
- name: Build Frontend
run: |
cd $GITHUB_WORKSPACE/frontend &&
cp .env.example .env.local &&
sed -i -r "s|NEXT_PUBLIC_DRUPAL_BASE_URL.*|NEXT_PUBLIC_DRUPAL_BASE_URL=http://localhost|g" .env.local &&
cd $GITHUB_WORKSPACE &&
drush su-next-connect >> $GITHUB_WORKSPACE/frontend/.env.local &&
cd $GITHUB_WORKSPACE/frontend &&
yarn &&
yarn build
7 changes: 4 additions & 3 deletions app/[...slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ export const generateMetadata = async ({params}: PageProps): Promise<Metadata> =
}

export const generateStaticParams = async (): Promise<PageProps["params"][]> => {
if (process.env.BUILD_COMPLETE !== "true") return []
const nodes = await getAllNodes()
return nodes.map(node => ({slug: node.path.split("/").filter(part => !!part)}))
const pagesToBuild = parseInt(process.env.BUILD_PAGES || "0")
if (pagesToBuild === 0) return []
const nodePaths = (await getAllNodes()).map(node => ({slug: node.path.split("/").filter(part => !!part)}))
return pagesToBuild < 0 ? nodePaths : nodePaths.slice(0, pagesToBuild)
}

export default Page
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"lint": "next lint && tsc",
"storybook": "storybook dev -p 6006",
"graphql": "DOTENV_CONFIG_PATH=./.env.local graphql-codegen --config codegen.ts -r dotenv/config",
"postinstall": "git config --local core.hooksPath .githooks/"
"postinstall": "git config --local core.hooksPath .githooks/ && exit 0"
},
"dependencies": {
"@formkit/auto-animate": "^0.8.2",
Expand Down

0 comments on commit a3ed7f8

Please sign in to comment.