Skip to content

Commit

Permalink
project ESlint clean up and PR template upload
Browse files Browse the repository at this point in the history
  • Loading branch information
qiyundai committed Mar 16, 2024
1 parent 48c9811 commit de00b0d
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/*
scripts/fallback.js
web-test-runner.config.js
4 changes: 4 additions & 0 deletions .github/codeql/codeql-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: "Milo Events CodeQL Config"

paths-ignore:
- node_modules
7 changes: 7 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Describe your specific features or fixes

Resolves: [MWPW-NUMBER](https://jira.corp.adobe.com/browse/MWPW-NUMBER)

Test URLs:
- Before: https://main--events-milo--adobecom.hlx.page/
- After: https://<branch>--events-milo--adobecom.hlx.page/
66 changes: 66 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ "main", "stage" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main", "stage" ]
schedule:
- cron: '18 6 * * 5'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
config-file: ./.github/codeql/codeql-config.yml

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
40 changes: 40 additions & 0 deletions .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Tests and Linting
on:
push:
branches: [ "main", "stage" ]
pull_request:
types: [opened, synchronize, reopened, edited]
branches: [ "main", "stage" ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 2

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Install XVFB
run: sudo apt-get install xvfb

- name: Install dependencies
run: npm ci

- name: Run linters
run: npm run lint

- name: Run the tests
run: xvfb-run -a npm test

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: coverage/lcov.info
10 changes: 3 additions & 7 deletions scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,15 @@ export function decorateArea(area = document) {
};

(async function loadLCPImage() {
const marquee = document.querySelector('.marquee');
const marquee = area.querySelector('.marquee');
if (!marquee) {
eagerLoad(document, 'img');
eagerLoad(area, 'img');
return;
}

// First image of first row
eagerLoad(marquee, 'div:first-child img');
// Last image of last column of last row
eagerLoad(marquee, 'div:last-child > div:last-child img');
}());
}

export async function useMiloSample() {
const { createTag } = await import(`${getLibs()}/utils/utils.js`);
}
1 change: 0 additions & 1 deletion utils/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

export function getMetadata(name) {
const attr = name && name.includes(':') ? 'property' : 'name';
const $meta = document.head.querySelector(`meta[${attr}="${name}"]`);
Expand Down

0 comments on commit de00b0d

Please sign in to comment.