diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 00000000..0a6b1d0a --- /dev/null +++ b/.eslintignore @@ -0,0 +1,3 @@ +node_modules/* +scripts/fallback.js +web-test-runner.config.js diff --git a/.github/codeql/codeql-config.yml b/.github/codeql/codeql-config.yml new file mode 100644 index 00000000..5856b626 --- /dev/null +++ b/.github/codeql/codeql-config.yml @@ -0,0 +1,4 @@ +name: "Milo Events CodeQL Config" + +paths-ignore: + - node_modules diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000..20c787bd --- /dev/null +++ b/.github/pull_request_template.md @@ -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://--events-milo--adobecom.hlx.page/ diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 00000000..72800233 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -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}}" diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml new file mode 100644 index 00000000..8c1ad582 --- /dev/null +++ b/.github/workflows/run-tests.yaml @@ -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 diff --git a/scripts/utils.js b/scripts/utils.js index b98aedb6..b083010b 100644 --- a/scripts/utils.js +++ b/scripts/utils.js @@ -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`); -} diff --git a/utils/utils.js b/utils/utils.js index c83a1d96..63ba4092 100644 --- a/utils/utils.js +++ b/utils/utils.js @@ -1,4 +1,3 @@ - export function getMetadata(name) { const attr = name && name.includes(':') ? 'property' : 'name'; const $meta = document.head.querySelector(`meta[${attr}="${name}"]`);