Short answer. Under MACRS, a roof follows the building it is on: 27.5 years under the General Depreciation System for residential rental property and 39 years for nonresidential real property, both straight-line with the mid-month convention. Under the Alternative Depreciation System, the periods are 30 and 40 years for property placed in service after 2017.
GDS versus ADS
GDS, the default: 27.5 years for residential rental property, 39 years for nonresidential.
ADS: 30 years for residential rental property placed in service after 2017, 40 years for nonresidential. It is required in some cases, such as when a real property business elects out of the business interest limit, and available by election.
Why a roof is not 15-year property
Qualified improvement property, which gets a 15-year life, covers certain interior improvements to nonresidential buildings. Roofs are not interior and do not qualify. Land improvements such as driveways and fences can be 15-year property, but a roof is part of the building itself.
Section 179 for some roofs
For tax years beginning after 2017, roofs on nonresidential real property can be expensed under Section 179, subject to annual limits and business income. Residential rental buildings do not qualify.
Recovery tables
Publication 946 has the percentage tables. For residential rental property, a full year is about 3.636 percent of cost, with a smaller first year depending on the month placed in service.