Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

chore(ci): correctly deploy code and docs on version branches and tags #17060

Closed
wants to merge 3 commits into from

Conversation

gkalpak
Copy link
Member

@gkalpak gkalpak commented Aug 2, 2020

Previously, the generated build artifacts and docs were only deployed for builds associated with the master branch. There was also a latest branch mentioned in the config, but there is normally no such branch, so this had no effect.

This commit fixes the rules so that deployments happen when necessary.
More specifically:

  • The deploy-code job now runs for builds associated with:
    • The master branch.
    • The stable branch (i.e. the branch from which the version tagged as @latest on npm is released).
    • Tags of the form v1.X.Y(-Z). (This also required configuring CircleCI to run builds for git tags, which does not happen by default.)
  • The deploy-docs job now runs for builds associated with:
    • The stable branch (i.e. the branch from which the version tagged as @latest on npm is released).

The new rules for when deployments should take place are based on the logic previously in .travis.yml and scripts/travis/build.sh (from before we switched from Travis to CircleCI).

As mentioned in `RELEASE.md`, now that the [CDN][1] has been updated
with the 1.8.0 version, it is safe to bump the value of the
`branchVersion` property in `package.json` to `^1.8.0`. This will cause
the docs app to use the latest version, namely 1.8.0.

[1]: https://ajax.googleapis.com/ajax/libs/angularjs/1.8.0/angular.js
@gkalpak gkalpak force-pushed the chore-fix-deployment branch 6 times, most recently from ec2e14b to 619ad1a Compare August 2, 2020 23:08
@gkalpak gkalpak force-pushed the chore-fix-deployment branch from 619ad1a to 7f673e1 Compare August 3, 2020 22:28
@gkalpak gkalpak changed the title Chore fix deployment chore(ci): correctly deploy code and docs on version branches and tags Aug 3, 2020
@gkalpak gkalpak force-pushed the chore-fix-deployment branch from 7f673e1 to 7b8da86 Compare August 3, 2020 22:38
Previously, the generated build artifacts and docs were only deployed
for builds associated with the master branch. There was also a `latest`
branch mentioned in the config, but there is normally no such branch, so
this had no effect.

This commit fixes the rules so that deployments happen when necessary.
More specifically:
- The `deploy-code` job now runs for builds associated with:
  - The master branch.
  - The stable branch (i.e. the branch from which the version tagged as
    `@latest` on npm is released).
  - Tags of the form `v1.X.Y(-Z)`. (This also required configuring
    CircleCI to run builds for git tags, which does not happen by
    default.)
- The `deploy-docs` job now runs for builds associated with:
  - The stable branch (i.e. the branch from which the version tagged as
    `@latest` on npm is released).

The new rules for when deployments should take place are based on the
logic previously in [.travis.yml][1] and [scripts/travis/build.sh][2]
(from before we switched from Travis to CircleCI).

[1]: https://github.com/angular/angular.js/blob/974700af7c1/.travis.yml#L54-L103
[2]: https://github.com/angular/angular.js/blob/974700af7c1/scripts/travis/build.sh#L66-L101
Copy link
Contributor

@Splaktar Splaktar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@g-patel
Copy link

g-patel commented Aug 11, 2020

@gkalpak Thanks much for doing this work for the old framework that is Angular1.x.
Are we waiting on some before it can be merged? I don't want to be pushy, but I am curious as to the 1.8 version of the docs is what is referenced from the main site, and I believe is treated as source of truth for LTS/support.

@Splaktar
Copy link
Contributor

@g-patel most like we'll need @petebacondarwin to review this and approve it as well.

FYI: the AngularJS LTS blog post was updated to include the Covid-19 extension of the LTS.

@Splaktar Splaktar mentioned this pull request Aug 11, 2020
4 tasks
@g-patel
Copy link

g-patel commented Aug 11, 2020

@g-patel most like we'll need @petebacondarwin to review this and approve it as well.

FYI: the AngularJS LTS blog post was updated to include the Covid-19 extension of the LTS.

Thanks for reply @Splaktar. Good to know that the blog post has been updated. 👍

Copy link
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one minor question - otherwise LGTM

- custom_attach_workspace
- init_environment
- skip_unless_stable_branch
- run: yarn grunt prepareDeploy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed since the deploy-docs job requires the prepare-deployment job?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is still necessary, because we are not persisting all affected files to the workspace.

Currently, the prepareDeploy command will affect files in the deploy/ and scripts/docs.angularjs.org-firebase/ directories and also create a firebase.json file at the root directory, but we only persist the deploy/ directory.

I guess we could persist the whole ng/ directory and not require this, though. I'll update the PR.

…oy-docs` CI job

Previously, the `grunt prepareDeploy` command was run in both the
`prepare-deployment` and `deploy-docs` CI jobs. The reason was that not
all files affected by `grunt prepareDeploy` were persisted to the
workspace across jobs.

More specifically, the command would affect files in the `deploy/` and
`scripts/docs.angularjs.org-firebase/` directories and also create a
`firebase.json` file at the root directory, but only the `deploy/`
directory was [persisted to the workspace][1].

This commit avoids unnecessarily running the `grunt prepareDeploy`
command in the `deploy-docs` CI job by ensuring that all affected files
will be persisted to the workspace in the `prepare-deployment` CI job,
which always runs before `deploy-docs`.

[1]: https://github.com/angular/angular.js/blob/295213df953766625462/.circleci/config.yml#L265
@gkalpak gkalpak force-pushed the chore-fix-deployment branch from 8abac0d to 7650afc Compare August 13, 2020 11:14
@gkalpak gkalpak closed this in 83f084e Aug 13, 2020
gkalpak added a commit that referenced this pull request Aug 13, 2020
…oy-docs` CI job

Previously, the `grunt prepareDeploy` command was run in both the
`prepare-deployment` and `deploy-docs` CI jobs. The reason was that not
all files affected by `grunt prepareDeploy` were persisted to the
workspace across jobs.

More specifically, the command would affect files in the `deploy/` and
`scripts/docs.angularjs.org-firebase/` directories and also create a
`firebase.json` file at the root directory, but only the `deploy/`
directory was [persisted to the workspace][1].

This commit avoids unnecessarily running the `grunt prepareDeploy`
command in the `deploy-docs` CI job by ensuring that all affected files
will be persisted to the workspace in the `prepare-deployment` CI job,
which always runs before `deploy-docs`.

[1]: https://github.com/angular/angular.js/blob/295213df953766625462/.circleci/config.yml#L265

Closes #17060
@gkalpak gkalpak deleted the chore-fix-deployment branch August 13, 2020 12:16
gkalpak added a commit to gkalpak/angular.js that referenced this pull request Aug 20, 2020
In angular#17060, the `deploy-code` job was updated to [include][1] the
`init_environment` step. This step assumes that the working directory is
`~/ng`. The `deploy-code` job uses the `cloud-sdk`, which
[did not specify a working directory][2]. As a result, the
`init_environment` step and subsequently the `deploy-code` job failed.
Examples failures: [on master][3], [on v1.8.x][4]

This commit fixes the issue by specifying a working directory for the
`cloud-sdk` executor. It also updates paths used in other steps of the
`deploy-code` job to take the working directory into account.

[1]: https://github.com/angular/angular.js/blob/83f084e5db95768dcee5302fa77924e1fb1f3239/.circleci/config.yml#L359
[2]: https://github.com/angular/angular.js/blob/83f084e5db95768dcee5302fa77924e1fb1f3239/.circleci/config.yml#L34-L37
[3]: https://app.circleci.com/pipelines/github/angular/angular.js/152/workflows/812df7b2-4bba-4e9e-a868-8c58db5d40d1/jobs/1594
[4]: https://app.circleci.com/pipelines/github/angular/angular.js/153/workflows/6a9826ac-d191-4042-8c39-0c969c81e381/jobs/1607
gkalpak added a commit to gkalpak/angular.js that referenced this pull request Aug 20, 2020
One step in the `deploy-docs` CI job contains a typo that causes it to
fail: `yarn -cwd ...` instead of `yarn --cwd ...`
This has been broken since a0488b3, but
has not been noticed because the job was not running. angular#17060 configured
the job to run as necessary, which brought up the error.
Example failure: [on v1.8.x][1]

This commit fixes the typo in the command.

[1]: https://app.circleci.com/pipelines/github/angular/angular.js/153/workflows/6a9826ac-d191-4042-8c39-0c969c81e381/jobs/1606
gkalpak added a commit to gkalpak/angular.js that referenced this pull request Aug 20, 2020
In angular#17060, the `deploy-code` job was updated to [include][1] the
`init_environment` step. This step assumes that the working directory is
ng`~/ng`. The `deploy-code` job uses the `cloud-sdk`, which
[did not specify a working directory][2]. As a result, the
`init_environment` step and subsequently the `deploy-code` job failed.

Examples failures:
  - On master:
    https://app.circleci.com/pipelines/github/angular/angular.js/
    152/workflows/812df7b2-4bba-4e9e-a868-8c58db5d40d1/jobs/1594
  - On v1.8.x:
    https://app.circleci.com/pipelines/github/angular/angular.js/
    153/workflows/6a9826ac-d191-4042-8c39-0c969c81e381/jobs/1607

This commit fixes the issue by specifying a working directory for the
`cloud-sdk` executor. It also updates paths used in other steps of the
`deploy-code` job to take the working directory into account.

[1]: https://github.com/angular/angular.js/blob/83f084e5db95768dcee5/.circleci/config.yml#L359
[2]: https://github.com/angular/angular.js/blob/83f084e5db95768dcee5/.circleci/config.yml#L34-L37
gkalpak added a commit to gkalpak/angular.js that referenced this pull request Aug 20, 2020
One step in the `deploy-docs` CI job contains a typo that causes it to
fail: `yarn -cwd ...` instead of `yarn --cwd ...`
This has been broken since a0488b3, but
has not been noticed because the job was not running. angular#17060 configured
the job to run as necessary, which brought up the error.

Example failure:
  - On v1.8.x:
    https://app.circleci.com/pipelines/github/angular/angular.js/
    153/workflows/6a9826ac-d191-4042-8c39-0c969c81e381/jobs/1606

This commit fixes the typo in the command.
gkalpak added a commit to gkalpak/angular.js that referenced this pull request Aug 20, 2020
In angular#17060, the `deploy-code` job was updated to [include][1] the
`init_environment` custom command. This caused the job to start failing,
because  the `init_environment` command was not compatible with the
`cloud-sdk` executor used in `deploy-code`. There were two problems:

1. The `init_environment` command assumes that the working directory is
   `~/ng`. The `cloud-sdk` executor [did not specify][2] a working
   directory.
   Example failures:
     - On master:
       https://app.circleci.com/pipelines/github/angular/angular.js/
       152/workflows/812df7b2-4bba-4e9e-a868-8c58db5d40d1/jobs/1594
     - On v1.8.x:
       https://app.circleci.com/pipelines/github/angular/angular.js/
       153/workflows/6a9826ac-d191-4042-8c39-0c969c81e381/jobs/1607

2. The `install_java` step, which is part of the `init_environment`
   command, relies on `sudo`, which is not available in the `cloud-sdk`
   executor.
   Example failure:
   - [On a PR]:
     https://app.circleci.com/pipelines/github/angular/angular.js/
     160/workflows/2eed5cfa-751c-44ba-b825-1d6cd5ba3406/jobs/1660

This commit fixes the issues by:
1. Specifying a working directory for the `cloud-sdk` executor. It also
   updates paths used in other steps of the `deploy-code` job to take
   the working directory into account.
2. Removing the `install_java` step from the `init_environment` command
   and adding it explicitly to jobs than require it.

[1]: https://github.com/angular/angular.js/blob/83f084e5db95768dcee5/.circleci/config.yml#L359
[2]: https://github.com/angular/angular.js/blob/83f084e5db95768dcee5/.circleci/config.yml#L34-L37
gkalpak added a commit to gkalpak/angular.js that referenced this pull request Aug 20, 2020
One step in the `deploy-docs` CI job contains a typo that causes it to
fail: `yarn -cwd ...` instead of `yarn --cwd ...`
This has been broken since a0488b3, but
has not been noticed because the job was not running. angular#17060 configured
the job to run as necessary, which brought up the error.

Example failure:
  - On v1.8.x:
    https://app.circleci.com/pipelines/github/angular/angular.js/
    153/workflows/6a9826ac-d191-4042-8c39-0c969c81e381/jobs/1606

This commit fixes the typo in the command.
gkalpak added a commit to gkalpak/angular.js that referenced this pull request Aug 20, 2020
In angular#17060, the `deploy-code` job was updated to [include][1] the
`init_environment` custom command. This caused the job to start failing,
because  the `init_environment` command was not compatible with the
`cloud-sdk` executor used in `deploy-code`. There were two problems:

1. The `init_environment` command assumes that the working directory is
   `~/ng`. The `cloud-sdk` executor [did not specify][2] a working
   directory.
   Example failures:
     - On master:
       https://app.circleci.com/pipelines/github/angular/angular.js/
       152/workflows/812df7b2-4bba-4e9e-a868-8c58db5d40d1/jobs/1594
     - On v1.8.x:
       https://app.circleci.com/pipelines/github/angular/angular.js/
       153/workflows/6a9826ac-d191-4042-8c39-0c969c81e381/jobs/1607

2. The `install_java` step, which is part of the `init_environment`
   command, relies on `sudo`, which is not available in the `cloud-sdk`
   executor.
   Example failure:
   - [On a PR]:
     https://app.circleci.com/pipelines/github/angular/angular.js/
     160/workflows/2eed5cfa-751c-44ba-b825-1d6cd5ba3406/jobs/1660

This commit fixes the issues by:
1. Specifying a working directory for the `cloud-sdk` executor. It also
   updates paths used in other steps of the `deploy-code` job to take
   the working directory into account.
2. Removing the `install_java` step from the `init_environment` command
   and adding it explicitly to jobs than require it.

[1]: https://github.com/angular/angular.js/blob/83f084e5db95768dcee5/.circleci/config.yml#L359
[2]: https://github.com/angular/angular.js/blob/83f084e5db95768dcee5/.circleci/config.yml#L34-L37
gkalpak added a commit to gkalpak/angular.js that referenced this pull request Aug 20, 2020
One step in the `deploy-docs` CI job contains a typo that causes it to
fail: `yarn -cwd ...` instead of `yarn --cwd ...`
This has been broken since a0488b3, but
has not been noticed because the job was not running. angular#17060 configured
the job to run as necessary, which brought up the error.

Example failure:
  - On v1.8.x:
    https://app.circleci.com/pipelines/github/angular/angular.js/
    153/workflows/6a9826ac-d191-4042-8c39-0c969c81e381/jobs/1606

This commit fixes the typo in the command.
gkalpak added a commit that referenced this pull request Aug 21, 2020
In #17060, the `deploy-code` job was updated to [include][1] the
`init_environment` custom command. This caused the job to start failing,
because  the `init_environment` command was not compatible with the
`cloud-sdk` executor used in `deploy-code`. There were two problems:

1. The `init_environment` command assumes that the working directory is
   `~/ng`. The `cloud-sdk` executor [did not specify][2] a working
   directory.
   Example failures:
     - On master:
       https://app.circleci.com/pipelines/github/angular/angular.js/
       152/workflows/812df7b2-4bba-4e9e-a868-8c58db5d40d1/jobs/1594
     - On v1.8.x:
       https://app.circleci.com/pipelines/github/angular/angular.js/
       153/workflows/6a9826ac-d191-4042-8c39-0c969c81e381/jobs/1607

2. The `install_java` step, which is part of the `init_environment`
   command, relies on `sudo`, which is not available in the `cloud-sdk`
   executor.
   Example failure:
   - [On a PR]:
     https://app.circleci.com/pipelines/github/angular/angular.js/
     160/workflows/2eed5cfa-751c-44ba-b825-1d6cd5ba3406/jobs/1660

This commit fixes the issues by:
1. Specifying a working directory for the `cloud-sdk` executor. It also
   updates paths used in other steps of the `deploy-code` job to take
   the working directory into account.
2. Removing the `install_java` step from the `init_environment` command
   and adding it explicitly to jobs than require it.

[1]: https://github.com/angular/angular.js/blob/83f084e5db95768dcee5/.circleci/config.yml#L359
[2]: https://github.com/angular/angular.js/blob/83f084e5db95768dcee5/.circleci/config.yml#L34-L37
gkalpak added a commit that referenced this pull request Aug 21, 2020
One step in the `deploy-docs` CI job contains a typo that causes it to
fail: `yarn -cwd ...` instead of `yarn --cwd ...`
This has been broken since a0488b3, but
has not been noticed because the job was not running. #17060 configured
the job to run as necessary, which brought up the error.

Example failure:
  - On v1.8.x:
    https://app.circleci.com/pipelines/github/angular/angular.js/
    153/workflows/6a9826ac-d191-4042-8c39-0c969c81e381/jobs/1606

This commit fixes the typo in the command.
gkalpak added a commit that referenced this pull request Aug 21, 2020
In #17060, the `deploy-code` job was updated to [include][1] the
`init_environment` custom command. This caused the job to start failing,
because  the `init_environment` command was not compatible with the
`cloud-sdk` executor used in `deploy-code`. There were two problems:

1. The `init_environment` command assumes that the working directory is
   `~/ng`. The `cloud-sdk` executor [did not specify][2] a working
   directory.
   Example failures:
     - On master:
       https://app.circleci.com/pipelines/github/angular/angular.js/
       152/workflows/812df7b2-4bba-4e9e-a868-8c58db5d40d1/jobs/1594
     - On v1.8.x:
       https://app.circleci.com/pipelines/github/angular/angular.js/
       153/workflows/6a9826ac-d191-4042-8c39-0c969c81e381/jobs/1607

2. The `install_java` step, which is part of the `init_environment`
   command, relies on `sudo`, which is not available in the `cloud-sdk`
   executor.
   Example failure:
   - [On a PR]:
     https://app.circleci.com/pipelines/github/angular/angular.js/
     160/workflows/2eed5cfa-751c-44ba-b825-1d6cd5ba3406/jobs/1660

This commit fixes the issues by:
1. Specifying a working directory for the `cloud-sdk` executor. It also
   updates paths used in other steps of the `deploy-code` job to take
   the working directory into account.
2. Removing the `install_java` step from the `init_environment` command
   and adding it explicitly to jobs than require it.

[1]: https://github.com/angular/angular.js/blob/83f084e5db95768dcee5/.circleci/config.yml#L359
[2]: https://github.com/angular/angular.js/blob/83f084e5db95768dcee5/.circleci/config.yml#L34-L37
gkalpak added a commit that referenced this pull request Aug 21, 2020
One step in the `deploy-docs` CI job contains a typo that causes it to
fail: `yarn -cwd ...` instead of `yarn --cwd ...`
This has been broken since a0488b3, but
has not been noticed because the job was not running. #17060 configured
the job to run as necessary, which brought up the error.

Example failure:
  - On v1.8.x:
    https://app.circleci.com/pipelines/github/angular/angular.js/
    153/workflows/6a9826ac-d191-4042-8c39-0c969c81e381/jobs/1606

This commit fixes the typo in the command.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants