aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2021-07-09 16:26:55 -0400
committerGitHub <noreply@github.com>2021-07-09 16:26:55 -0400
commitc46d129780a6de2cc228704621731ec5db399674 (patch)
treec89d2c48b0395778c72cef44a312a1d4def8f9c3 /.github/workflows
parent43ecd21c4391ed86aa1daa64f1afb8c3c9ab49f5 (diff)
downloadtranslated-content-c46d129780a6de2cc228704621731ec5db399674.tar.gz
translated-content-c46d129780a6de2cc228704621731ec5db399674.tar.bz2
translated-content-c46d129780a6de2cc228704621731ec5db399674.zip
build and upload built artifacts like mdn/content (#814)
* build and upload built artifacts like mdn/content * remove {{languages}} macro call * hardcode upload path * use env var * debuggin * debuggin * debuggin * debuggin * debuggin * debugging rsync * debug more * debug more * cleanup * debugging * try this * try this * use 'HEAD~1' * try this * debug this * debug this * debug this * -l 1 * testing something * testing something (2) * testing something (3) * try git fetch -n origin * can git diff work now? * trying something more * trying something more (2) * trying something more (3) * try with the right working-directory * better sha? * fix a bunch of images in a Polish page
Diffstat (limited to '.github/workflows')
-rw-r--r--.github/workflows/pr-test.yml101
1 files changed, 73 insertions, 28 deletions
diff --git a/.github/workflows/pr-test.yml b/.github/workflows/pr-test.yml
index e7627ef857..45701450ac 100644
--- a/.github/workflows/pr-test.yml
+++ b/.github/workflows/pr-test.yml
@@ -17,6 +17,10 @@ jobs:
steps:
- uses: actions/checkout@v2
+ # Needed otherswise it will check out a merge commit which means
+ # you can't get a `git diff` for this PR compared to its base.
+ # with:
+ # ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/checkout@v2
with:
@@ -74,25 +78,18 @@ jobs:
env:
CONTENT_ROOT: ${{ github.workspace }}/mdn/content/files
CONTENT_TRANSLATED_ROOT: ${{ github.workspace }}/files
- working-directory: ${{ github.workspace }}/mdn/content
- run: |
- echo ${{ env.GIT_DIFF_CONTENT }}
-
- # Some day, when our number of flaws have reached 0 we'll change
- # this to "*:error" which means the slightest flaw in the build
- # will break the build.
- # See https://github.com/mdn/yari/issues/715
- export BUILD_FLAW_LEVELS="unsafe_html: error, *:ignore"
-
- # Note, it might be interesting to explore building *some*
- # pages in a PR build if the diff doesn't have any index.html
- # files changed.
- # Instead of building the git diff, you build some known typical
- # folders that you know don't take too long and do cover a lot
- # of interesting macros etc.
- # This way, when an edit to the source code comes in, perhaps the
- # functional tests have a gap in them but actually building
- # real content exposes it.
+
+ # This is so that if there's a single 'unsafe_html' flaw, it
+ # completely fails the build.
+ # But all other flaws should be 'warn' so that we can include
+ # information about the flaws when we analyze the built PR.
+ BUILD_FLAW_LEVELS: "unsafe_html: error, *:warn"
+
+ # Because we build these pages in a way that you get a toolbar,
+ # so the flaws can be displayed, but we don't want any of the
+ # other toolbar features like "Fix fixable flaws" or "Quick-edit"
+ # we set this to disable that stuff.
+ REACT_APP_CRUD_MODE_READONLY: true
# Setting this to an empty string effectively means that the
# <iframe> src will end up being the relative URL of the current
@@ -104,24 +101,72 @@ jobs:
# whatever code is inserted into the code example. But since the
# whole (possible) domain for PR builds will never be somewhere
# where there are interesting cookies, it's a safe choice.
- export BUILD_LIVE_SAMPLES_BASE_URL=
+ BUILD_LIVE_SAMPLES_BASE_URL: ""
# In these builds we never care for or need the ability to sign in.
# This environment variable will disable that functionality entirely.
- export REACT_APP_DISABLE_AUTH=true
+ REACT_APP_DISABLE_AUTH: true
+
+ # TODO: This should be implicit when `CI=true`
+ BUILD_NO_PROGRESSBAR: true
# If we don't do this the built files will end up in
# `node_modules/@mdn/yari/client/build/` and we don't want that
# to get pushed into the cache.
- export BUILD_OUT_ROOT=/tmp/
+ BUILD_OUT_ROOT: /tmp/build
+
+ working-directory: ${{ github.workspace }}/mdn/content
+ run: |
+ mkdir -p $BUILD_OUT_ROOT
+
+ # Don't use `yarn build` (from mdn/content) because that one hardcodes
+ # the BUILD_OUT_ROOT and CONTENT_ROOT env vars.
+ node node_modules/@mdn/yari/build/cli.js ${{ env.GIT_DIFF_CONTENT }}
+
+ echo "Disk usage size of build/"
+ du -sh $BUILD_OUT_ROOT
- export BUILD_NO_PROGRESSBAR=true
- # The reason this script isn't in `package.json` is because
- # you don't need that script as a writer. It's only used in CI
- # and it can't use the default CONTENT_ROOT that gets set in
- # package.json.
+ # Save the PR number into the build
+ echo ${{ github.event.number }} > $BUILD_OUT_ROOT/NR
- yarn build ${{ env.GIT_DIFF_CONTENT }}
+ - name: Generate the diff file
+ if: ${{ env.GIT_DIFF_CONTENT }}
+ env:
+ # This must match what we set in the "Build changed content" step above
+ BUILD_OUT_ROOT: /tmp/build
+ run: |
+ # Save the raw diff blob and store that inside the ./build/
+ # directory.
+ # The purpose of this is for the PR Review Companion to later
+ # be able to use this raw diff file for the benefit of analyzing.
+ git diff --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.sha }} > $BUILD_OUT_ROOT/DIFF
+
+ - name: Merge static assets with built documents
+ if: ${{ env.GIT_DIFF_CONTENT }}
+ env:
+ # This must match what we set in the "Build changed content" step above
+ BUILD_OUT_ROOT: /tmp/build
+ run: |
+ rsync -a ${{ github.workspace }}/mdn/content/node_modules/@mdn/yari/client/build/ $BUILD_OUT_ROOT/
+
+ # Now that build/ directory contains everything you need to deploy
+ # that as a site. HTML, static assets, images, etc.
+ # However, that Yari static files is very heavy and it's in large
+ # part due to the .map files.
+ # In fact, as of March 2021, the client/build/static directory
+ # is 2.3MB but only 864KB without all the .map files.
+ # Let's delete those this time because this isn't the right time
+ # to debug JS or CSS.
+ find $BUILD_OUT_ROOT/static -type f -name "*.map" | xargs rm
+
+ - uses: actions/upload-artifact@v2
+ if: ${{ env.GIT_DIFF_CONTENT }}
+ env:
+ # This must match what we set in the "Build changed content" step above
+ BUILD_OUT_ROOT: /tmp/build
+ with:
+ name: build
+ path: ${{ env.BUILD_OUT_ROOT }}
- uses: technote-space/get-diff-action@v4.1.1
with: