Test against GitHub and cran version of a dependency, allow_fail only on the latter

I want to allow failure on only the part of the build matrix that has the cran version. However, this code seems to allow failure everywhere:

jobs:
  include:
  - r: release
    r_github_packages: r-lib/usethis
  - r: devel
    r_github_packages: r-lib/usethis
  - r: release
  - r: devel
  allow_failures:
  - r: release
    r_github_packages:
  - r: devel
    r_github_packages:

What am I doing wrong?

I think the problem here is that you cannot match a job by the absence of value.

jobs:
  include:
  - r: release
    r_github_packages: r-lib/usethis
  - r: devel
    r_github_packages: r-lib/usethis
  - r: release
  - r: devel
  allow_failures:
  - r: release
    r_github_packages: # <---
  - r: devel
    r_github_packages: # <---

I think these lines are effectively no-op, and the configuration amounts to:

jobs:
  # ⋮
  allow_failures:
    - r: release
    - r: devel

which matches all of the defined jobs.

One way to get around this problem is to introduce a auxiliary environment variable to indicate whether or not the job should be allowed to fail.

jobs:
  include:
  - r: release
    r_github_packages: r-lib/usethis
  - r: devel
    r_github_packages: r-lib/usethis
  - r: release
    env: ALLOW=true
  - r: devel
    env: ALLOW=true
  allow_failures:
  - env: ALLOW=true

Thank you very much that solved my problem. Very kind of you to provide
a copy-n-paste ready solution!